Hi Fabinao,
From your description, you'd like to build a master detailed databind
asp.net webform page. In the page you use a DataGrid to display the main
records and when one recored in the datagrid is selected, those textboxes
or dropdownlists or .. will be filled with the certain selected record's
detailed data. And when we want to add record, those fields will be cleared
,yes?
As for this problem, here are my suggestions:
1. Retrieved the master-detailed datas from the databse when the web form
page is first time loaded(using DataSet). Then store them in some place for
later use, maybe in Session or ViewState.
2. Then bind the master table's records with the DataGrid control, note you
need to provide a button column in the datagrid which is used to let the
user select a certain row of record. When first time loaded, bind those
textboxes or dropdownlist's value with the first record's detailed value.
3. Then when a certain record's row's button is clicked, in the
serverside's click event(datagrid's itemcommand event) retrieve the certain
selected record's datas and fill them in the textboxes or dropdownlists....
4. If you want to provide insert function, you can add a "Add" button and
in its "click" event, you can use code to clear all the textboxes or other
fields' value and let the user to input new record's value. And then after
user click submit, in the submit button's click event, insert the new
record and update the local dataset.
If you fill it abit too complex, you can view the following turoial in the
ASP.NET Quickstart:
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdatalist.aspx
Also, here are some more detailed tech articles on master-detailed
databinding:
#HOW TO: Create a Master/Detail Page with Web Form Controls
http://support.microsoft.com/?id=308485
#Master-Detail DataGrids in ASP.Net...
http://www.dotnetjohn.com/articles/articleid14.aspx
#Creating Master-Detail Listings using ASP.NET controls
http://www.dotnetbips.com/displayarticle.aspx?id=184
#Building DataBound Templated Custom ASP.NET Server Controls
http://msdn.microsoft.com/library/en-us/dnaspp/html/databoundtemplatedcontro
ls.asp?frame=true
Hope also helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx