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

How to access rowindex in radgrid template column?

1 Answer 376 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harshit
Top achievements
Rank 1
Harshit asked on 19 Sep 2011, 06:39 PM
           <Columns>     
               <telerik:GridTemplateColumn HeaderText="Support" UniqueName="SupportUsed">                     <ItemTemplate>                         <telerik:RadComboBox ID="ddlSupportUsed" runat="server" EmptyMessage="All Types"  OnClientSelectedIndexChanging="IndexChanged2"                          Width="200px" OnClientDropDownClosed="onDropDownClosing" >                         <ItemTemplate>                             <div onclick="StopPropagation(event)" >
                                <asp:CheckBox runat="server" ID="chk1" onclick="onCheckBoxClick(this)"/>                             </div>                         </ItemTemplate>                                              </telerik:RadComboBox>                     </ItemTemplate>                 </telerik:GridTemplateColumn>             </Columns>

















Here is how my grid layout looks like. I want to access grid rowindex of grid row when I click checkbox within dropdown in grid. How can I achieve this?

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Sep 2011, 11:20 AM
Hello Harshit,

Try the following code snippet to access rowindex in Combobox ItemTemplate.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
   {
     GridDataItem item = (GridDataItem)e.Item;
     RadComboBox combob1 = (RadComboBox)item.FindControl("ddlSupportUsed");
     CheckBox chk1 = (CheckBox)combob1.Items[0].FindControl("chk1");
     chk1.Attributes.Add("onclick", "clickEvent(" + item.ItemIndex + ")");
   }
}
JS:
<script type="text/javascript">
function clickEvent(index)
{
  alert(index);
}
</script>

Thanks,
Princy.
Tags
Grid
Asked by
Harshit
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or