I have a WebDataGrid where EnableAjax="false." One of the columns contains an ImageButton, as follows:
<Columns> <ig:BoundDataField DataFieldName="FileName" Key="FileName"> <Header CssClass="WebDataGrid_Header" Text="File Name" /> </ig:BoundDataField> <ig:TemplateDataField Key="Delete"> <ItemTemplate> <asp:ImageButton ID="imgDelete" OnClick="DeleteClick" CausesValidation="false" CommandName="D" ImageUrl="~/images/icon_delete.gif" runat="server" /> </ItemTemplate> </ig:TemplateDataField> </Columns>
The Click Event for the image button is as follows:
protected void DeleteClick(object sender, EventArgs e) {
}
But, when I click the button, the event never fires. Can anyone explain why, and possibly provide a solution?
Hello Craig,
If you would like to handle control events coming inside of cell form WebDataGrid the correct way to do this is as you handle the ItemCommand event handler of the grid :
Column template declaration:
<ig:TemplateDataField Key="hah">
<Header Text="Template" />
<ItemTemplate>
<asp:ImageButton ImageUrl="n_1_01.gif" runat="server"
CommandArgument="args" CommandName="D"
ID="ImageButton1" />
</ItemTemplate>
</ig:TemplateDataField>
Register the handler:
protected void Page_Load(object sender, EventArgs e)
{
WebDataGrid1.ItemCommand +=
new Infragistics.Web.UI.GridControls.ItemCommandEventHandler(WebDataGrid1_ItemCommand);
Run your custom logic here based on your scenario.
void WebDataGrid1_ItemCommand(object sender,
Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)
string commandName = e.CommandName;
object commandArgs = e.CommandArgument;
e.Handled = true;
Hope this helps you.
Let me know if you have any questions with this.
I've tried your code but the code inside load( ) event is not working. Can you tell me how to solve the problem ?
new Infragistics.Web.UI.GridControls.ItemCommandEventHandler
Hello,
Attached is working sample showing how to use ItemCommand along with asp ImageButton control. ig_res folder was removed from the website due to upload size limitation.
Hope this helps.
How would I databind the commandArgument to include the PKey of the row?
Assuming it is in a column called RowPKey
Thanks
jack
Hello guys,
Please have a look at the attached sample.
Hope it helps.
hi RadoSlav,
The Image button onCommand event is not firing in the Infragistics webdatagrid 14.2 but it working when we are using the Infragistics 12.1