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

Server Side Event in Item Template of Rad Grid

2 Answers 194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dotnetrockerzzz
Top achievements
Rank 2
dotnetrockerzzz asked on 28 Dec 2010, 03:30 PM
I have a RadGrid there is Item template in it containing a asp.net Hyperlink . I want that, onclick of this hyperlink some event in code behind to be fired with respect to the that Item. I have the event code written in the CSharp. Is that possible ? How ?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 29 Dec 2010, 05:23 AM
Hello,


You could use LinkButton (instead of HyperLink) and set the CommandName for the control. Now the ItemCommand event gets fired when clicking the LinkButton. Check for the CommandName and perform the server code in ItemCommand event.

Server code:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "MyCommandName")
    {
        GridDataItem dataItem = (GridDataItem)e.Item;
        // Your code here
    }
}

Mark-up:
<Columns>
    <telerik:GridTemplateColumn>
        <ItemTemplate>
            <asp:LinkButton ID="LinkButton1" CommandName="MyCommandName" runat="server">LinkButton</asp:LinkButton>
        </ItemTemplate>
    </telerik:GridTemplateColumn>



-Shinu.
0
dotnetrockerzzz
Top achievements
Rank 2
answered on 29 Dec 2010, 05:01 PM
Thank You for your answer , It helped
Tags
Grid
Asked by
dotnetrockerzzz
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
dotnetrockerzzz
Top achievements
Rank 2
Share this question
or