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";
}
}
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";
}
}