CheckBoxes in DataGrids-- the "checked" attribute not correct after posting page?

  • Thread starter Thread starter Jim Bancroft
  • Start date Start date
J

Jim Bancroft

Hi everyone,

I'm using a DataGrid with TemplateColumns. My DataGrid is located in a cell
of an asp:Table. I did this so it's positioned correctly onscreen.

One of the DataGrid's TemplateColumns is a checkbox. During the page's
postback I loop over the DataGrid and read the checkbox values. My problem
is, none of the checkboxes ever have their "Checked" attribute set-- it's as
though anything I mark is ignored.

If I put a checkbox outside of the DataGrid, into a separate cell of my
table, I can read its Checked attribute correctly during postback. Is there
something I'm missing here when it comes to placing checkboxes into DataGrid
columns? I enabled the viewstate on my checkbox, but that didn't help. If
you have any suggestions or tips, I'm all ears. Thanks!
 
Check if you have datagrid's viewstate enabled.
Check if you re-bind your data in postback. If you do, the selection info
will be lost.
 
Yes, that was it. I had inadvertently bound my DataGrid during postback, so
the checkboxes lost their state. Many thanks Ting!
 
Yeah with CheckBoxes thats the trick
Patrick


Jim Bancroft said:
Yes, that was it. I had inadvertently bound my DataGrid during postback, so
the checkboxes lost their state. Many thanks Ting!
 
Can you post your code where you check your grid for what checkbox has been
clicked? I have a similar app where I need to check each row to see what
radio group has been selected.

thanks in advance
 
Back
Top