Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a reference of a checkbox 1

Status
Not open for further replies.

RamHardikar

Programmer
Feb 16, 2001
109
GB
Is there a way to get the reference of a checkbox which sits in the header column of the DataGrid in the code behind?
 
Have a look at the FindControl method to locate a checkbox within a DataGrid

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
i tried doing this, but it returns me nothing -

CheckBox cc;
cc = (CheckBox) DG.FindControl("chkAll");

Am I doing this wrong?
 
how do i refer a header row in a DataGrid? if i am able to do that then maybe i can refer to my checkbox there this way -

c = (CheckBox) DG.Items[headerrowid].FindControl("chkAll");
 
Try using the ItemCreated or ItemDataBound events and use e.Item.FindControl

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
And to check if the row is a header row use something like:
Code:
If e.Item.ItemType = ListItemType.Header Then

End If

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
i could catch that control in ItemCreated event. Thankx a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top