Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

Seeking C# Solution to Dataset updating via Datagrid

Mar 11 2003 12:50 PM
I am a newbie to .Net and appreciate any C# guru out there that could help provide me a solution to following two issues. I currently have a datagrid datasource set to a dataset. Within this datagrid I have 5 columns only one of which do I want to be editable. All my columns are bound columns except for one template column. I created an Item template for my PrimaryProvider column that uses a dropdownlist control. My users don't want to switch from viewing to editing and back again. So the column is always viewable as a dropdown list control. Now I have been able to set the datasource for the dropdown list and populate it with the necessary values. However, my first issue is this, how do I programatically make the selected value for each dropdownlist within each datagrid row match the PrimaryProviderID value that is stored in the dataset if the column is not null. Also, if dataset PrimaryProvider ID column is null i need the dropdown to have an blank value selected. I added a blank row to the datasource of the dropdown list during page load. Second, since my users do not wish to fire an update command for each row. Upon clicking a save button and leaving the page I need to know how to programatically iterate through all the datagrid rows and update each record in the dataset with any new values for the PrimaryProviderId column and deal with null values if the user still has not selected a PrimaryProvider before saving. Any help is much appreciated. A link to another post that discusses these same issues would also be appreciated. Thanks, Oscar.

Answers (1)