This is a migrated thread and some comments may be shown as answers.

[Solved] Find the Checkbox in Radgrid trhrough Code Behind

1 Answer 444 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 22 Jul 2009, 08:00 AM
Specified argument was out of the range of valid values. Parameter name: index


 Dim myCheckbox As CheckBox = CType(dgi.Cells(0).Controls(1), CheckBox)


How to find any controls value in Radgrid ?
How to ?






1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Jul 2009, 08:15 AM
Hi Rahul,

I guess you are trying to access the CheckBox inside a GridTemplateColumn in code behind. If so you may try the following code snippet to achieve the desired scenario. If not you may consider sending your aspx page.

//here is the code to access template controls in code behind
ASPX:
 
<telerik:GridTemplateColumn UniqueName="CheckBoxCol"  HeaderText="CheckBoxCol" > 
          <ItemTemplate> 
              <asp:CheckBox ID="CheckBox1" runat="server" /> 
          </ItemTemplate> 
         </telerik:GridTemplateColumn> 

VB:
 
 
  Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) 
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
            Dim chkbx As CheckBox = DirectCast(item("CheckBoxCol").FindControl("CheckBox1"), CheckBox) 
        End If 
    End Sub 
 

You can use the column's UniqueName property to access the cells in RadGrid.
Accessing cells and rows

Thanks
Shinu
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or