checkbox problems in datagrid

J

John

Hi all, i've added a checkbox column to my datagrid using template columns,
and i added a checkbox to the header for check all and uncheck all
functionality. the purpose of this is to allow the users to select records
from the list and add them to another list when the push a button. My
problem is that the checked value never survives postback. in other words i
can find the controls, i used some online articles to figure out how to do
this, but the chkbox.checked value is always false even if i hard code it to
be true in the html. i've tried both asp:checkbox and HtmlInputControl
checkboxes, both have the same problem. i've also tried with and without
paging enabled on the datagrid and nothing helps.
heres the c# code i'm using to try to get the values

foreach( DataGridItem di in dgListData.Items )
{
if(di.FindControl("chkInclude")!=null)
Trace.Write("in foreach");
HtmlInputCheckBox chkBx =
(HtmlInputCheckBox)di.FindControl("chkInclude") ;

if( chkBx !=null )
{
Trace.Write("In if",chkBx.Checked.ToString()+" value
"+chkBx.Value.ToString());
lblIncludeError.Visible=true;
lblIncludeError.Text="It worked";
}
}
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top