OnItemCommand not working with ImageButton and OK with LinkButton

Discussion in 'ASP .Net Web Controls' started by Harley, Sep 14, 2004.

  1. Harley

    Harley Guest

    I have a Template column with 2 imagebuttons and 1 linkbutton.
    The OnItemCommand handler defined on the DataGrid control is not fired when
    I click the imagebuttons, but works perfectly with the linkbutton.
    I'm posting the code so someone can take a look and hopelfully has an idea
    of what I'm doing wrong. Thank you!

    PS: the dtagagrid is on a UserControl, i'm posting the code for the user
    control.
    PS2: to wire the handler, I used both approaches, via HTML OnItemCommand
    defined on the datagrid's HTML code and I added a "Handles
    controlName.ItemCommand" to the OnItemCommand handler signature on the VB
    code.
    PS3: note the CommandName and CommandArgument defined for each control.


    ctrlPending.ascx
    -------------------
    <asp:datagrid id="dtgPendientes" runat="server" BorderColor="#999999"
    BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3"
    AllowSorting="True" AutoGenerateColumns="False"
    OnItemCommand="dtgPendientes_Procesar">
    .......
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:ImageButton id=imbDetail runat="server" Tooltip="Ver Detalle"
    CommandArgument='<%# Container.DataItem("in_tkt_code")%>'
    CommandName="Detail" Width="16px" Height="16px"
    ImageUrl="../images/interface/ico_view.gif"></asp:ImageButton>
    <asp:ImageButton id=imbClose runat="server" Tooltip="Cancelar Incidente"
    CommandArgument='<%# Container.DataItem("in_tkt_code")%>' CommandName="Close"
    Width="16px" Height="16px"
    ImageUrl="../images/interface/ico_cancel.gif"></asp:ImageButton>
    <asp:LinkButton id="LinkButton1" runat="server" CommandArgument='<%#
    Container.DataItem("in_tkt_code")%>'
    CommandName="Detail">LinkButton</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>

    ctrlPending.ascx.vb (the code behind for the control)
    -----------------------
    Sub dtgPendientes_Procesar(ByVal objSender As Object, ByVal objArgs As
    DataGridCommandEventArgs) Handles dtgPendientes.ItemCommand
    ........
    End Sub
    Harley, Sep 14, 2004
    #1
    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. Rick White
    Replies:
    1
    Views:
    1,586
    Natty Gur
    Jan 13, 2004
  2. Sathyaish
    Replies:
    3
    Views:
    3,079
    Sathyaish
    Sep 8, 2005
  3. MichiMichi
    Replies:
    0
    Views:
    433
    MichiMichi
    May 29, 2007
  4. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    171
    Sathyaish
    Sep 8, 2005
  5. Andrew Backer
    Replies:
    0
    Views:
    202
    Andrew Backer
    Mar 15, 2005
Loading...

Share This Page