Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a asp linkbutton inside a Telerik GridTemplateColumn. When I click on the link button, I should be able to get the index of the row I clicked.
I am not able to achieve this. The event that fires when I click the link button has arguments as " object sender, EventArgs e". Had it been GridDataItem instead of EventArgs, I would have got the value of e and used it.
Please suggest a simple way in which I can get the row index. Below is the snippet of the code which isnt giving me the proper value.

.aspx :

<telerik:gridtemplatecolumn itemstyle-horizontalalign="Center" xmlns:telerik="#unknown">
<itemstyle bordercolor="Black" borderwidth="1px" horizontalalign="center" font-bold="false">
Font-Size="11px" BackColor="White" Width="30px" />
<itemtemplate>
<asp:LinkButton OnClientClick="DisableAllButtons();" OnClick="ConditionHistoryLinkButton_Click"
ID="ConditionHistoryLink" runat="server" Text="Hist" />


.cs :
protected void ConditionHistoryLinkButton_Click(object sender, EventArgs e)
{

GridDataItem item = (GridDataItem)(sender as LinkButton).NamingContainer;
int rowIndex = item.RowIndex;
}

Any help is very much appreciated. Thanks !
Posted
Comments
virusstorm 19-Jun-15 7:42am    
Can you post your Telerik RadGrid definition?
gpthakur 19-Jun-15 7:57am    
<telerik:RadGrid runat="server" ID="ConditionStatusRadGrid" Height="230px" Width="990px"
AutoGenerateColumns="false" GridLines="Both" BackColor="Transparent" HorizontalAlign="Center"
EnableEmbeddedSkins="false" AllowPaging="True">
<exportsettings exportonlydata="True">

<clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
<scrolling allowscroll="True" usestaticheaders="True">
<Selecting AllowRowSelect="true" />


<mastertableview showheader="false">
<columns>
<telerik:gridboundcolumn datafield="ConditionKey" itemstyle-horizontalalign="Center">
<itemstyle bordercolor="Black" borderwidth="1px" horizontalalign="center" font-bold="false"
="" font-size="11px" backcolor="White" width="30px">

<telerik:gridboundcolumn datafield="ConditionDescription" itemstyle-horizontalalign="Center">
<itemstyle bordercolor="Black" borderwidth="1px" horizontalalign="center" font-bold="false"
="" font-size="11px" backcolor="White" width="200px">

<telerik:gridtemplatecolumn itemstyle-horizontalalign="Center">
<itemstyle bordercolor="Black" borderwidth="1px" horizontalalign="center" font-bold="false"
="" font-size="11px" backcolor="White" width="30px">
<itemtemplate>
<asp:LinkButton OnClientClick="DisableAllButtons();" OnClick="ConditionHistoryLinkButton_Click"
ID="ConditionHistoryLink" runat="server" Text="Hist" />




virusstorm 19-Jun-15 8:14am    
My experience with Telerik controls is you should Telerik controls with Telerik Controls. Take a look at this:
http://www.telerik.com/help/sitefinity/developer-manual/radgrid.net2-telerik.webcontrols.gridbuttoncolumn.html

Also, Telerik has excellent support forums and you can create an account for free. You might want to post this question there if you haven't already. They tend to take a day or two, but someone usually gets back to you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900