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

[Solved] Find the Row Index for a Rad Grid

1 Answer 297 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ttaylor29
Top achievements
Rank 1
ttaylor29 asked on 29 May 2013, 12:10 PM

How can I find the row index for a Rad grid? I want to pass the row index and 'this' to a javascript function to toggle the checkboxes on my rad grid from telerik.

Something like this: onClick="Checkbox(this, rowindex);"

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 29 May 2013, 12:46 PM
Hello,

Please try with the following code,and check if this helps you.

ASPX:
<telerik:GridTemplateColumn>
      <ItemTemplate>
         <asp:CheckBox ID="CheckBox1" runat="server" />
      </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem gd=(GridDataItem)e.Item;
        CheckBox chk = (CheckBox)gd.FindControl("CheckBox1");
        int index = gd.ItemIndex;
        chk.Attributes.Add("OnClick", "Click('" + index + "','"+chk.ClientID+"')");
    }
}

JAVASCRIPT:
<script type="text/javascript">
   function Click(id, checkid)
 {
       alert(id);
 }
</script>

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