Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / ItemCommand not firing. what's wrong here?

ItemCommand not firing. what's wrong here?

New Discussion
Roger Tristan
Roger Tristan asked on Aug 27, 2018 8:06 AM
This looks right to me? but when I put a breakpoint in ItemCommand, it never fires when I click the button. what’s the deal? am I missing something?
The grid is manuall bount by
grid.datasource = dtData
grid.Databind()
<ig:WebDataGrid ID=”wgDowntime” runat=”server” AutoGenerateColumns=”False” Height=”350px” Width=”1110px” OnItemCommand=”wgDowntime_ItemCommand” >
<Columns>
            <ig:TemplateDataField Key=”DelButton” >
<Header Text=””></Header>
<ItemTemplate>
<asp:Button runat=”server” ID=”btnDelete” Text=”Delete” CommandName=”Delete1″ CommandArgument='<%# Eval(“MachineID”).ToString()  %>’ CssClass=”myButton”></asp:Button>
</ItemTemplate>
</ig:TemplateDataField>
        </Columns>
</ig:WebDataGrid>
<br />
Sign In to post a reply

Replies

  • 0
    Galina Edinakova
    Galina Edinakova answered on Aug 27, 2018 8:06 AM

    Hello Roger,

    I believe the same issue is discussed in this thread as well. As Jason states there, the reason the ItemCommand event is not firing is that templates of the grid are instantiated in the DataBind method of the grid. Normally if this method is not manually called it gets called during the OnPreRender event for the grid. However, when using this with the ItemCommand the DataBind event is fired after the ItemCommand event is supposed to fire. Since the templates haven’t been instantiated in time the event can’t find the templates and fails out silently.

    So in order to resolve this issue you need to call the EnsureTemplates() method as follows:

    if (IsPostBack) {
    
       WebDataGrid1.EnsureTemplates();
    
    }

    I implemented this approach in the attached sample application and I confirmed it worked. Please, review the sample and let us know if you need further assistance on the matter.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Roger Tristan
Favorites
0
Replies
2
Created On
Aug 27, 2018
Last Post
7 years, 6 months ago

Suggested Discussions

Created by

Created on

Aug 27, 2018 8:06 AM

Last activity on

Feb 12, 2026 7:43 PM