|
Subject:
|
DetailsView Issue.
|
|
Posted By:
|
midway11
|
Post Date:
|
9/1/2006 2:36:13 PM
|
Hi there,
I am using a GridView and displaying details in a Detailsview control. Now then I select a Row in the Gridview the details on for that record shows on the Detailsview control, but when there is/are not related records on the detailsview, the detailsview does not show at all. the functionality that I'm looking for is when I select a Row on the Gridview, if that specific record does not have a related record or the PrimaryKey does not exist on the details table, I want the detailsview to automatically goes on Insert Mode so the user can star creating detail records for the parent record.
Now, how can I tell when the detailsview control did not bring any records from the database?
Thanks very much.
Midway
|
|
Reply By:
|
peace95
|
Reply Date:
|
9/15/2006 10:48:18 PM
|
Midway: It would helpful to know how your database tables, in the parent-child relationship tables reference in your topic. However, my response is based on the relationship " each and every child (or detail record MUST belong or have one and only one Parent(master record). This would also means that a child record would not exist unless there was a Parent record, but a Parent record could exist, but no child/children records. Consider the following as part of the resolution:
1--As part of your Parent record you could highlight or underline or have a bit-switch to indicate the Parent or Master record is without the child or detail records.
2--Or displayed with each Parent record have an "Add Detail" Button if the Detail record already exist, then the "Add Detail"Button would be "grayed out".
One way to test the above: In a query, you could match the parent record with child record indicating a LEFT JOIN making a temp table, the query the temp table for blank child record. A Query, using the RIGHT JOIN will indicate blank parent records. I hope this did not confuse you more, if so email me.
I hope this helps.
|
|
Reply By:
|
drewid
|
Reply Date:
|
11/29/2006 5:55:12 PM
|
I have the same question/issue that midway11 has, but would need to deal with it programmatically. Take the following scenario - I have an entry in the aspnet_users table after login and then want to create a corresponding record in a different table based on that username. If I automatically go directly to a detailsview to be able to edit/view the information it just returns a blank screen since there is no data yet in that second table, instead of being able to do an insert. How can you get it to do an insert if there is no data found in the select query for that detailsview?
Thanks, this is a very important issue I am trying to tackle.
|
|
Reply By:
|
peace95
|
Reply Date:
|
11/30/2006 4:35:28 AM
|
drewid: It is not clear from your scenario "the when" you would want this event to occur, right after the login? Do you use _VIEWSTATE? And/or Page_Init?
|
|
Reply By:
|
drewid
|
Reply Date:
|
12/1/2006 2:08:46 PM
|
Actually I would want to go to the detailsview after account creation (I am using the wizard). The FinishDestinationPageUrl would go to this page.
I am having issues getting this to default into an insert view, which would then go to a detail view after the insert. I can set the default to insert, but it then goes back to a blank insert screen after it inserts the record.
Ideal scenario: 1) Account is created 2) Next page is additional account details (I used the captured UserName on this page - is working fine) 3) The intial view on the additional account details page is an "insert" view so the additional account details record can be created in the corresponding table. 4) After insert it then takes me to a "details" view
*) Ideally I'd like to be able to use this same page to "insert" a record if no corresponding record exists; or "view" the information if a record does exist.
|
|
Reply By:
|
virendar23
|
Reply Date:
|
12/4/2006 10:51:34 AM
|
Hi , first of all , u cant do it. Only empty data template is displayed when there is no data to bound. So think of other way of design.If there is no data, then emptydata template is displayed.U can place button in that template with "add new data " text. Then u can make the details view to insert mode.
|