Use a datarelation to automatically populate and save info from datagrid dropdowns
Posted on 2004-04-20
Environment: ASP.NET web application, VB.net server side code, SQL Server 2k database
I have a datagrid and, to simplify the problem, let's say that it contains two columns: ClientName and InsideSales
I have a dataset that contains two datatables - Clients and Sales. Clients has a SalesID column and that is the primary key of the Sales table. I know how to create the dataset, the datatables, and the appropriate datarelation for SalesID.
I would like the following functionality:
1) The datagrid should populate and display SalesName.
2) When a row is edited, the Sales drop-down should default to the correct SalesName of course.
3) If the user chooses a new SalesName from the drop down and saves the row, the logic should automatically save the appropriate salesID in the Clients table.
Can this be done with the datarelation? I would like to do it this way if so. Does the datarelation somehow bind that chosen drop down id to the Client table SalesID?