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
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.
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.
if(e. Commandname =="Delete")
{
}
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.
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