By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

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

P: n/a

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!
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
"Jim Bancroft" wrote:

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!

Nov 19 '05 #2

P: n/a
Yes, that was it. I had inadvertently bound my DataGrid during postback, so
the checkboxes lost their state. Many thanks Ting!
"Ting Huang" <Ti*******@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
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
"Jim Bancroft" wrote:

Nov 19 '05 #3

P: n/a
Yeah with CheckBoxes thats the trick
Patrick
"Jim Bancroft" <sd****@jsdfk.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
Yes, that was it. I had inadvertently bound my DataGrid during postback, so the checkboxes lost their state. Many thanks Ting!
"Ting Huang" <Ti*******@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
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
"Jim Bancroft" wrote:


Nov 19 '05 #4

P: n/a
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
"Jim Bancroft" <as******@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

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!

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.