0
votes

I have a Telerik GridView which contains several columns of which a few columns are link-buttons. I want to access the text of that link button upon clicking on it in code behind. I want to access only the particular column text which is clicked in code behind. My code is follows

<telerik:gridtemplatecolumn 
        datafield="EmployeeHRId" 
        filtercontrolalttext="Filter EmployeeHRId column"
        headertext="Employee HR ID" 
        sortexpression="EmployeeHRId" 
        uniquename="EmployeeHRId">
    <ItemTemplate>
        <asp:LinkButton ID="LBEmpHRId" runat="server"  
                EmpHRId='<%#Eval("EmployeeHRId") %>' 
                CssClass="EmpHrIdCss">
            <%#Eval("EmployeeHRId")%>
        </asp:LinkButton>
    </ItemTemplate>
</telerik:gridtemplatecolumn>

Please help me with this

1
What about a ForEach loop in the YourGrid.Items ? - cubitouch
on which event? a linkbutton click or RowCommand - naveen

1 Answers

1
votes

Haven't used TelerikGrid but the basic step is you will have to Find the control in the RowCommand event or similar that TelerikGrid exposed.

LinkButton lb = e.Item.FindControl("LBEmpHRId") as LinkButton;
string id = lb.Text;

//Alternately you can pass HRId as a CommandArgument of your LinkButton as well.

I found this sample which says TelerikGrid has ItemCommand that you will have to handle.