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

[Solved] telerik:RadGrid <ItemTemplate> ImageButton EventTrapping

4 Answers 654 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pramod
Top achievements
Rank 1
Pramod asked on 21 May 2008, 10:42 AM

Hi,

Is there any way we can handle the ImageButton event in <ItemTemplate> of a Teleric Rad Grid, rather then using the LinkButton.

I am binding OnItemCommand="GeneralRadGrid_ItemCommand" and providing the CommandName="Edit" on <ItemTemplete><asp:ImageButton ImageUrl="../images/bt_edit.gif" ID="EditImageButton" runat="server" CommandName="Edit" /></ItemTemplate>

But I am not able get to the handler
protected void GeneralRadGrid_ItemCommand(object source, GridCommandEventArgs e){
    if (e.CommandName == "Edit")
    {
        Response.Redirect(
"GeneralClassification.aspx");
    }
}

Kindly let me know the way to do so, earlier my teammate posted the same issue but did not got the code to run.

Thanks,
Pramod Singh

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 May 2008, 11:53 AM
Hi Pramod,

Try with the Click event of the ImageButton as shown below.

ASPX:
 <telerik:GridTemplateColumn UniqueName="TempCol" > 
                         <ItemTemplate> 
                             <asp:ImageButton ID="ImageButton1" runat="server" CommandName="Image" OnClick="ImageButton1_Click" /> 
                         </ItemTemplate> 
                        </telerik:GridTemplateColumn> 


CS:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)  
    {  
        Response.Redirect("GeneralClassification.aspx");  
    } 


Thanks
Princy.
0
Pramod
Top achievements
Rank 1
answered on 21 May 2008, 01:00 PM
 Hi Princy,

I understand what you mean to say, but what if I need to get the column ID(or any data) for that particular row click.

Kindly help if this is possible to trap GeneralRadGrid_ItemCommand with the LinkButton as can be performed in any normal GridView control.


Thanks,
Pramod Singh
0
Shinu
Top achievements
Rank 2
answered on 22 May 2008, 07:50 AM
Hi Pramod,

I was able to fire the ItemCommand event on clicking the ImageButton in the GridTemplateColumn. Can you try with a different CommandName other than "Edit" ?

ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" >  
                         <ItemTemplate>  
                             <asp:ImageButton ID="ImageButton1" runat="server" CommandName="DoEdit" />  
                         </ItemTemplate>  
                        </telerik:GridTemplateColumn>  


CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "DoEdit") 
        { 
            Response.Redirect("GeneralClassification.aspx"); 
 
        } 
 
    } 


Thanks
Shinu.

0
Pramod
Top achievements
Rank 1
answered on 22 May 2008, 08:29 AM
Hi Shinu,

Thanks for showing such a great patience.

I was able to do so, the fault was from my side. We have a base page template whereby the pageload was getting overriden, that was again binding the grid on EditIcon click of the grid ItemTemplate.

But not sure why this GeneralRadGrid_ItemCommand getting fired in case of LinkButton.


Thanks,
Pramod
Tags
Grid
Asked by
Pramod
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pramod
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or