Server Side Event in Item Template of Rad Grid

3 posts, 1 answers
  1. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 28 Dec 2010 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Dec 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 29 Dec 2010 Link to this post

    Thank You for your answer , It helped
Back to Top