all groups > asp.net datagrid control > july 2005 >
You're in the

asp.net datagrid control

group:

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


CheckBoxes in DataGrids-- the "checked" attribute not correct after posting page? Jim Bancroft
7/22/2005 4:02:33 PM
asp.net datagrid control:

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!

RE: CheckBoxes in DataGrids-- the "checked" attribute not correct afte Ting Huang
7/22/2005 6:28:01 PM
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.
--
Ting Huang


[quoted text, click to view]
Re: CheckBoxes in DataGrids-- the "checked" attribute not correct afte Jim Bancroft
7/23/2005 11:28:01 PM
Yes, that was it. I had inadvertently bound my DataGrid during postback, so
the checkboxes lost their state. Many thanks Ting!


[quoted text, click to view]

Re: CheckBoxes in DataGrids-- the "checked" attribute not correct afte Patrick.O.Ige
7/24/2005 12:00:00 AM
Yeah with CheckBoxes thats the trick
Patrick


[quoted text, click to view]

Re: CheckBoxes in DataGrids-- the "checked" attribute not correct after posting page? GJH
8/4/2005 12:19:51 PM
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


[quoted text, click to view]

AddThis Social Bookmark Button