Matt
Matt

Reputation: 5660

Click Event for ImageButton Inside RadGrid

I have an asp.net ImageButton inside a RadGrid (in a column) that when clicked opens a popup window. I can also expand this same RadGrid to reveal a nested grid. I have a button inside here that I need to assign a click event to such that it opens the same popup. How do I fire off an ImageButton click that's housed inside a RadGrid?

Here is the aspx and the "imgEdit" is what I need to fire off:

 <MasterTableView DataKeyNames="SuggestionID">
    <EditFormSettings CaptionFormatString="Edit Suggestion: {0}" CaptionDataField="Title"
        InsertCaption="Add Suggestion" EditFormType="WebUserControl" PopUpSettings-Width="655px"
        UserControlName="~/CommonUserControls/SuggestionControl.ascx">
    </EditFormSettings>
    <Columns>
        <telerik:GridTemplateColumn UniqueName="EditAction" HeaderStyle-Width="32px" ItemStyle-Wrap="false"
            Resizable="false">
            <ItemTemplate>
                <asp:ImageButton ID="imgEdit" runat="server" CommandName="Edit" Resizable="false" 
                    ImageUrl="/ESDNET/Images/Icons/pencil.png" ToolTip="Edit Suggestion" Visible='<%# Eval("CanEdit") %>' />

Upvotes: 2

Views: 4335

Answers (1)

Saritha.S.R
Saritha.S.R

Reputation: 800

You can achieve the same in different ways:

1) Directly attach the button click event of imagebutton

 protected void imgEdit_Click(object sender, ImageClickEventArgs e)
    {
             // your code
    }

2) Using CommandName:

protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if(e.CommandName=="Edit")
        {

        }
    }

3) If the commandname is Edit ,then it will autometically fire EditCommand

protected void RadGrid1_EditCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {

    }

Upvotes: 2

Related Questions