Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 06, 2012 05:12 AM by praveen.singh
Jul 10, 2008 09:35 AM|LINK
i am trying to access CheckBox in headertemplate of datagrid, soon after binding data to the grid in the pageindexchanged event.
i get a NullReferenceException when i do that. Could not find the reason. i have already done this accessing of header control elsewhere in my application, but have not had any problem before. Is it any thing to do with the pageindexchanged event.
i access the header control using
i have done the same in the _selectAllChkBx onCheckedChange Event.
Jul 10, 2008 11:46 AM|LINK
CheckBox chkSelect = (CheckBox)GridView1.HeaderRow.FindControl("chkSelect"); // here in paranthesis of findcontrol() method, give the id of checkox in headertemplate.
Jul 10, 2008 11:56 AM|LINK
it is not a grid view, it is a datagrid. Datagrid does not have a property called HeaderRow. I sorted out the issue by fetching the header control using Datagrid.Controls.Controls.
What i am not able to understand is, in CheckedChange event of control in itemtemplate of the datagrid i fetched using Datagrid.Controls.Controls, whereas in pageIndexChanged event i fetched it as Datagrid.Controls.Controls. what is the difference.
how does grid structure differ in the above two cases. wierd....
Jul 10, 2008 12:09 PM|LINK
MyCheckBox = (CheckBox)DataGrid1.Items(0).FindControl("CheckBox1");
For further detail.
Jul 10, 2008 12:20 PM|LINK
DataGrid1.Items(0) will return the first item row and will not return the header row.
Jul 11, 2008 06:54 AM|LINK
Hi anupreethi2001 ,
Try this way:
Nov 06, 2012 05:12 AM|LINK
Thanks Dear Its solv my problem