DataGrid not calling ItemCommand Event

Discussion in 'ASP .Net Web Controls' started by Ezequiel Pérez, Apr 11, 2006.

  1. Hi, I have a problem with a DataGrid, this datagrid is not calling the
    ItemCommand event. I tried do to it defining the event as usual (from
    the designer), but it didn't work, neither defining the event in the .aspx.

    the aspx datagrid tag:

    <asp:datagrid id="grdOilFields" runat="server" BorderColor="#999999"
    GridLines="Vertical" HorizontalAlign="Center"
    AutoGenerateColumns="False" Font-Names="Arial" Font-Size="X-Small"
    CssClass="cssTabla" OnItemCommand="grdOilFields_ItemCommand">
    <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    <ItemStyle Height="24px" ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
    <HeaderStyle Height="24px"></HeaderStyle>
    <Columns>
    <asp:BoundColumn HeaderText="Descripción">
    <HeaderStyle Width="145px" CssClass="LeftHeaderImage"></HeaderStyle>
    <ItemStyle Width="145px"></ItemStyle>
    </asp:BoundColumn>
    <asp:TemplateColumn>
    <HeaderStyle Width="45px" CssClass="RightHeaderImage"></HeaderStyle>
    <ItemStyle Width="45px"></ItemStyle>
    <ItemTemplate>
    <asp:ImageButton id="btnDelete" runat="server"
    ImageUrl="../Images/Buttons/DGDelete.gif"
    CommandName="btnDelete"></asp:ImageButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>

    the way I defined the event handler:

    protected void grdOilFields_ItemCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    ... some code which is never reached ...
    }

    if you have any ideas about why this event is never reached, please tell
    me, thanks
     
    Ezequiel Pérez, Apr 11, 2006
    #1
    1. Advertising

  2. Ezequiel Pérez

    Alvin Bruney Guest

    do you have data available?

    --
    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The Microsoft Office Web Components Black Book with .NET
    Now Available @ www.lulu.com/owc
    Forth-coming VSTO.NET - Wrox/Wiley 2006
    -------------------------------------------------------

    "Ezequiel Pérez" <> wrote in message
    news:...
    > Hi, I have a problem with a DataGrid, this datagrid is not calling the
    > ItemCommand event. I tried do to it defining the event as usual (from the
    > designer), but it didn't work, neither defining the event in the .aspx.
    >
    > the aspx datagrid tag:
    >
    > <asp:datagrid id="grdOilFields" runat="server" BorderColor="#999999"
    > GridLines="Vertical" HorizontalAlign="Center" AutoGenerateColumns="False"
    > Font-Names="Arial" Font-Size="X-Small" CssClass="cssTabla"
    > OnItemCommand="grdOilFields_ItemCommand">
    > <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    > <ItemStyle Height="24px" ForeColor="Black"
    > BackColor="#EEEEEE"></ItemStyle>
    > <HeaderStyle Height="24px"></HeaderStyle>
    > <Columns>
    > <asp:BoundColumn HeaderText="Descripción">
    > <HeaderStyle Width="145px" CssClass="LeftHeaderImage"></HeaderStyle>
    > <ItemStyle Width="145px"></ItemStyle>
    > </asp:BoundColumn>
    > <asp:TemplateColumn>
    > <HeaderStyle Width="45px" CssClass="RightHeaderImage"></HeaderStyle>
    > <ItemStyle Width="45px"></ItemStyle>
    > <ItemTemplate>
    > <asp:ImageButton id="btnDelete" runat="server"
    > ImageUrl="../Images/Buttons/DGDelete.gif"
    > CommandName="btnDelete"></asp:ImageButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:datagrid>
    >
    > the way I defined the event handler:
    >
    > protected void grdOilFields_ItemCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    > {
    > ... some code which is never reached ...
    > }
    >
    > if you have any ideas about why this event is never reached, please tell
    > me, thanks
     
    Alvin Bruney, Apr 12, 2006
    #2
    1. Advertising

  3. Ezequiel Pérez

    Jeff Dillon Guest

    Try adding a Select command type column to the grid, from the designer

    "Ezequiel Pérez" <> wrote in message
    news:...
    > Hi, I have a problem with a DataGrid, this datagrid is not calling the
    > ItemCommand event. I tried do to it defining the event as usual (from the
    > designer), but it didn't work, neither defining the event in the .aspx.
    >
    > the aspx datagrid tag:
    >
    > <asp:datagrid id="grdOilFields" runat="server" BorderColor="#999999"
    > GridLines="Vertical" HorizontalAlign="Center" AutoGenerateColumns="False"
    > Font-Names="Arial" Font-Size="X-Small" CssClass="cssTabla"
    > OnItemCommand="grdOilFields_ItemCommand">
    > <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    > <ItemStyle Height="24px" ForeColor="Black"
    > BackColor="#EEEEEE"></ItemStyle>
    > <HeaderStyle Height="24px"></HeaderStyle>
    > <Columns>
    > <asp:BoundColumn HeaderText="Descripción">
    > <HeaderStyle Width="145px" CssClass="LeftHeaderImage"></HeaderStyle>
    > <ItemStyle Width="145px"></ItemStyle>
    > </asp:BoundColumn>
    > <asp:TemplateColumn>
    > <HeaderStyle Width="45px" CssClass="RightHeaderImage"></HeaderStyle>
    > <ItemStyle Width="45px"></ItemStyle>
    > <ItemTemplate>
    > <asp:ImageButton id="btnDelete" runat="server"
    > ImageUrl="../Images/Buttons/DGDelete.gif"
    > CommandName="btnDelete"></asp:ImageButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:datagrid>
    >
    > the way I defined the event handler:
    >
    > protected void grdOilFields_ItemCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    > {
    > ... some code which is never reached ...
    > }
    >
    > if you have any ideas about why this event is never reached, please tell
    > me, thanks
     
    Jeff Dillon, Apr 12, 2006
    #3
  4. Ezequiel Pérez

    Teemu Keiski Guest

    And you databind it initially inside if(!Page.IsPostBack){...} check?

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    "Ezequiel Pérez" <> wrote in message
    news:...
    > Hi, I have a problem with a DataGrid, this datagrid is not calling the
    > ItemCommand event. I tried do to it defining the event as usual (from the
    > designer), but it didn't work, neither defining the event in the .aspx.
    >
    > the aspx datagrid tag:
    >
    > <asp:datagrid id="grdOilFields" runat="server" BorderColor="#999999"
    > GridLines="Vertical" HorizontalAlign="Center" AutoGenerateColumns="False"
    > Font-Names="Arial" Font-Size="X-Small" CssClass="cssTabla"
    > OnItemCommand="grdOilFields_ItemCommand">
    > <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    > <ItemStyle Height="24px" ForeColor="Black"
    > BackColor="#EEEEEE"></ItemStyle>
    > <HeaderStyle Height="24px"></HeaderStyle>
    > <Columns>
    > <asp:BoundColumn HeaderText="Descripción">
    > <HeaderStyle Width="145px" CssClass="LeftHeaderImage"></HeaderStyle>
    > <ItemStyle Width="145px"></ItemStyle>
    > </asp:BoundColumn>
    > <asp:TemplateColumn>
    > <HeaderStyle Width="45px" CssClass="RightHeaderImage"></HeaderStyle>
    > <ItemStyle Width="45px"></ItemStyle>
    > <ItemTemplate>
    > <asp:ImageButton id="btnDelete" runat="server"
    > ImageUrl="../Images/Buttons/DGDelete.gif"
    > CommandName="btnDelete"></asp:ImageButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:datagrid>
    >
    > the way I defined the event handler:
    >
    > protected void grdOilFields_ItemCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    > {
    > ... some code which is never reached ...
    > }
    >
    > if you have any ideas about why this event is never reached, please tell
    > me, thanks
     
    Teemu Keiski, Apr 16, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick Gilbert
    Replies:
    2
    Views:
    889
    Jeffrey Tan[MSFT]
    Dec 15, 2003
  2. Utter Newbie
    Replies:
    3
    Views:
    3,737
    Utter Newbie
    Oct 5, 2004
  3. =?Utf-8?B?RGVlcGVzaA==?=

    Datagrid ItemCommand Event Not Firing

    =?Utf-8?B?RGVlcGVzaA==?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,817
    =?Utf-8?B?RGVlcGVzaA==?=
    Oct 6, 2005
  4. =?Utf-8?B?ZGFuYw==?=

    DataGrid ItemCommand event not firing if not first page

    =?Utf-8?B?ZGFuYw==?=, Oct 26, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,152
    =?Utf-8?B?ZGFuYw==?=
    Oct 26, 2005
  5. Ezequiel Pérez

    DataGrid not calling ItemCommand Event

    Ezequiel Pérez, Apr 11, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    150
    Teemu Keiski
    Apr 16, 2006
Loading...

Share This Page