I have two sections on my page: a set of controls on the top of the page that specify various controls for searching data, and a RadGrid below it that shows the results.
Inside the CommandItemTemplate of the RadGrid, I have a checkbox.
In an eventhandler not directly related to the grid itself (a button click) I need to get a reference to the Checkbox inside the command item template, but I can't seem to find the right way to get a reference.
Any suggestions? Here's a couple of snippets of different ways I tried to get a reference from the button click event.
The inner part of the for loop doesn't get hit because when inside the button click event handler, the if Item si GridCommandItem is always false.
Inside the CommandItemTemplate of the RadGrid, I have a checkbox.
In an eventhandler not directly related to the grid itself (a button click) I need to get a reference to the Checkbox inside the command item template, but I can't seem to find the right way to get a reference.
Any suggestions? Here's a couple of snippets of different ways I tried to get a reference from the button click event.
The inner part of the for loop doesn't get hit because when inside the button click event handler, the if Item si GridCommandItem is always false.
<CommandItemTemplate> |
<asp:CheckBox ID="chkMyCheckBox" Style="float: left" runat="server" Text="My Checkbox" TextAlign="Right" AutoPostBack="true" OnCheckChanged="chkMyCheckBox_CheckChanged" /> |
</CommandItemTemplate> |
Dim chk as CheckBox = DirectCast(dgMyGrid.FindControl("chkMyCheckBox"),CheckBox) |
For Each Item As GridItem In dgMyGrid.Items |
If Item Is GetType(Telerik.Web.UI.GridCommandItem) Then |
Dim CommandItem As GridCommandItem = DirectCast(Item, GridCommandItem) |
Dim Header As GridTHead = DirectCast(CommandItem.NamingContainer, GridTHead) |
Dim chk1 As CheckBox = DirectCast(Header.FindControl("chkMyCheckBox"), CheckBox) |
Dim chk2 As CheckBox = DirectCast(CommandItem.FindControl("chkMyCheckBox"), CheckBox) |
End If |
Next |