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

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!
 
G

Guest

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.
 
J

Jim Bancroft

Yes, that was it. I had inadvertently bound my DataGrid during postback, so
the checkboxes lost their state. Many thanks Ting!
 
P

Patrick.O.Ige

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!
 
G

GJH

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top