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

Binding OnitemCommand event

4 Answers 249 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raju Kumar
Top achievements
Rank 1
Raju Kumar asked on 14 May 2008, 08:18 AM
Hi,
 I need to invoke

OnItemCommand

 event on a click of a Image button under  <telerik:GridTemplateColumn>

I am able to do so on Linkbutton but not with Image button.

My code is this.


<

telerik:GridTemplateColumn UniqueName="TemplateColumnDelete" Groupable="False">

<HeaderStyle Width="45px"></HeaderStyle>

<ItemTemplate>

<asp:LinkButton ID="lnkButtonDelete" runat="server" CommandName="Delete" Text="delete"></asp:LinkButton>

<!-- <asp:ImageButton ID="imgButtonDel" ImageUrl="~/Images/bt_delete.gif" runat="server"

CommandName="Delete"></asp:ImageButton>-->

</ItemTemplate>

</telerik:GridTemplateColumn>


Thanks.
Raju.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2008, 09:40 AM
Hi Raju,

Are you checking the proper CommandName in the ItemCommand event? I was able to achieve this on my end. My code is as follows.

ASPX:
<telerik:GridTemplateColumn HeaderText="Temp" UniqueName="Temp" > 
                           <ItemTemplate> 
                               <asp:ImageButton ID="ImageButton1" CommandName="Delete"   ImageUrl="~/image1.gif"  runat="server"  /> 
                             
                           </ItemTemplate> 
                          </telerik:GridTemplateColumn> 


CS:
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Delete") 
        {  
         
        } 
   } 


Thanks
Shinu.

0
Raju Kumar
Top achievements
Rank 1
answered on 14 May 2008, 02:38 PM
Hi Shinu,
       I am still not able to solve my problem, I am doing the same thing what you have written, actually the problem is that, it is able to bind ItemCommand event on click of a link button but when i use Image Button the ItemCommand event is not occur. Can you please tell me the exact reason for this.

My code is like in ASPX

<

telerik:RadGrid

OnItemCommand

="InHouseRadGrid_ItemCommand"

 .......>

<MasterTableView Width="100%" AllowMultiColumnSorting="True">

<Columns>

<telerik:GridTemplateColumn UniqueName="TemplateColumnDelete" Groupable="False">

<HeaderStyle Width="45px"></HeaderStyle>

<ItemTemplate>

 <asp:ImageButton ID="imgButtonDel" ImageUrl="~/Images/bt_delete.gif" runat="server"

CommandName="Delete"></asp:ImageButton>

</ItemTemplate>

</telerik:GridTemplateColumn>

 </Columns>

</

MasterTableView>

</telerik:RadGrid>


And on c#

protected

void InHouseRadGrid_ItemCommand(object source, GridCommandEventArgs e)

{

}

NOTE::  The debugger is not coming on this event.
 

surendiran
Top achievements
Rank 1
commented on 08 May 2021, 07:03 AM

use below the code for your code behind file

if(e. Commandname =="Delete")
{
}
0
Shinu
Top achievements
Rank 2
answered on 15 May 2008, 05:20 AM
Hi Raju,

Have you set the Event Handler for the ItemCommand event in the aspx?

ASPX:
 <telerik:RadGrid ID="RadGrid1"    runat="server"   OnItemCommand="RadGrid1_ItemCommand"  > 


Thanks
Shinu.
0
mamad
Top achievements
Rank 2
answered on 23 May 2010, 09:43 PM
i have the same problem with image button in radgrid
when i used imagebutton the item command event not occur
but when i used link button or button the event occur true
please help me solve this problem
thank's
Tags
Grid
Asked by
Raju Kumar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Raju Kumar
Top achievements
Rank 1
mamad
Top achievements
Rank 2
Share this question
or