i have a datagrid and every row has a checkbox on it. also every field in every row can be updated
the user can update multiple rows and check any checkboxes.
at the click of the SUBMIT button all the data should be updated. i need the checkboxes to update a boolean (or what ever the bool type is for sql server) in a database.
- how do implement the checkboxes to be able to update the table in the DB?
- with the click of the submit button how do i get all the data to be updated?
Go through the datagrid and store all of the data that you want to update in arrays or the like. Sql server has a
bitdatatype and you can set it to0if the checkbox is off or1if it ischecked. Once you collect all the data pass it to your data layer for a sql updateYou can use the
DataGridobject to iterate through its cells/controls. For example, using a nested loop you can do:Edit: It depends on the input controls you have in the columns because you have to cast them. Say you have a datagrid with 10 columns and TextBoxes in all columns except the last, which is CheckBox, you would do:
You could use a 2D array/list to store if you wanted too. HTH