Fire button event in RadGrid

5 posts, 0 answers
  1. Simon
    Simon avatar
    5 posts
    Member since:
    Sep 2012

    Posted 13 Mar 2010 Link to this post


    I have a GridTemplateColumn where I define a TextBox and a Button in the EditItemTemplate property. How is it possible to fire the onClick event of the button.

    I have tried the following:
    <asp:ImageButton ID="Button" runat="server" ImageUrl="~/Resources/key.png" OnClick="Button_Click" />

    ... but this doesn't work I always get the following compilation error "...does not contain a definition for 'Button_Click' and no extension method ... (are you missing a using directive or an assembly reference?)".

    I don't know what I made wrong - can anybody help me?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Mar 2010 Link to this post

    Hello Simon,

    Have you added the Button_Click event on server code?


        protected void Button_Click(object sender, EventArgs e)  
            // Your code  

    Another option is setting the CommandName for button and check for the CommandName in ItemCommand event.


            <asp:ImageButton ID="ImageButton1" runat="server" CommandName="custom" />  


        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
            if (e.CommandName == "custom")  
                // Your code  

  3. Simon
    Simon avatar
    5 posts
    Member since:
    Sep 2012

    Posted 15 Mar 2010 Link to this post

    Hello Shinu!

    Thank you very much for your help.

    Now I have found what I made wrong. I have added the Butten_Click event on server code but I choosed the wrong access modifier for the methode - I haven't seen that, this was my mistake. Therefore I always get the error on compilation time.

    Now everything works. Thank you!

  4. Kokila
    Kokila avatar
    1 posts
    Member since:
    Mar 2016

    Posted 17 Mar 2016 in reply to Shinu Link to this post

    I am having a button on the header. On button click it should get the rows which has checkbox selected. i couldn't get the selected rows. because when there is postback the grid rebind the initial data.

    Please help

    Thanks in Advance

  5. Kostadin
    Kostadin avatar
    1733 posts

    Posted 22 Mar 2016 Link to this post

    Hi Kokila,

    I prepared a small sample where I get the selected items on the server. Please check out the attached sample and let me know how it differs form your real setup?

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top