ASP.NET Gridview Checkbox value to DataTable

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-04-14T15:25:08Z Indexed on 2010/04/14 16:33 UTC
Read the original article Hit count: 386

Filed under:
|
|
|
|

Hey all,

First off, im using a checkbox to highlight a true or false value from a dataset which I want to be able to change it. Unfortunately databinding the DataTable to the GridView checkboxes doesnt work (as you probably know) as it requires it to be in "edit" mode.

The way I've gotten round this is having the checkbox reading the data table value seperately rather than being databound and locked:

Checked='<%# Convert.ToBoolean(Eval("myValue")) %>'

So that solves checkbox values from DataTable -> GridView, now I need to do the opposite having the changed checkbox values go from GridView -> DataTable as it is not ready to submit it to my data source (SQL) just yet.

I figure I need to run a loop through the GridView rows, thats a give'un, what I can't figure out is how to replace/update just a single value in a row of a DataTable , only the ability to add or remove an entire row by the looks of things (something I don't want to do).

So can anyone offer a workaround? Or is there a way to have a databound but always editable checkbox in a gridview?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about gridview