Bug in DataGrid - ItemCommand event does not fire for ButtonColumnif ButtonType="PushButton"

Discussion in 'ASP .Net' started by Nick Gilbert, Dec 12, 2003.

  1. Nick Gilbert

    Nick Gilbert Guest

    We have a Datagrid which contains a template column with a button in it,
    as well as an actual button column. If either of the buttons are
    clicked, the ItemCommand event does not fire.

    If however, the ButtonType of the ButtonColumn is changed to
    "LinkButton" instead of "PushButton", the event fires normally!

    Why on earth is this happening? I presume this a bug in .NET? (We are
    using 1.1 final).

    <asp:DataGrid id="JobsDataGrid" runat="server"
    AutoGenerateColumns="False"
    DataKeyField="JobNumber" >
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:Button ID="RunJobButton" Runat="server"
    CommandName="RunJob"
    CommandArgument="1"
    Text="Run Task 1" />
    </ItemTemplate>

    </asp:TemplateColumn>
    <asp:ButtonColumn ButtonType="PushButton" CommandName="RunJob"
    Text="Run Task 2" />
    </Columns>
    </asp:DataGrid>

    Any ideas how to fix this would be appeciated.

    Nick...
    Nick Gilbert, Dec 12, 2003
    #1
    1. Advertising

  2. Re: Bug in DataGrid - ItemCommand event does not fire for ButtonColumn if ButtonType="PushButton"

    You might not be handling PostBack in the Page Load
    Try adding the statements
    if not Page.IsPostback then
    'your code
    end if

    "Nick Gilbert" <> wrote in message news:...
    > We have a Datagrid which contains a template column with a button in it,
    > as well as an actual button column. If either of the buttons are
    > clicked, the ItemCommand event does not fire.
    >
    > If however, the ButtonType of the ButtonColumn is changed to
    > "LinkButton" instead of "PushButton", the event fires normally!
    >
    > Why on earth is this happening? I presume this a bug in .NET? (We are
    > using 1.1 final).
    >
    > <asp:DataGrid id="JobsDataGrid" runat="server"
    > AutoGenerateColumns="False"
    > DataKeyField="JobNumber" >
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:Button ID="RunJobButton" Runat="server"
    > CommandName="RunJob"
    > CommandArgument="1"
    > Text="Run Task 1" />
    > </ItemTemplate>
    >
    > </asp:TemplateColumn>
    > <asp:ButtonColumn ButtonType="PushButton" CommandName="RunJob"
    > Text="Run Task 2" />
    > </Columns>
    > </asp:DataGrid>
    >
    > Any ideas how to fix this would be appeciated.
    >
    > Nick...
    Sonali.NET[MVP], Dec 12, 2003
    #2
    1. Advertising

  3. RE: Bug in DataGrid - ItemCommand event does not fire for ButtonColumn if ButtonType="PushButton"

    Hi Nick,

    I found that this post has been posted in several groups. I have added a
    reply to you in microsoft.public.dotnet.framework.aspnet.datagridcontrol.
    Please follow up there, I will work with you.
    Thanks for your understanding,

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Dec 15, 2003
    #3
    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. Replies:
    3
    Views:
    2,639
    Karl Seguin
    Feb 7, 2005
  2. Jimmy
    Replies:
    3
    Views:
    3,921
    Jimmy
    May 28, 2005
  3. Nick Gilbert
    Replies:
    4
    Views:
    246
    Jeffrey Tan[MSFT]
    Dec 16, 2003
  4. thijs braem via .NET 247

    ItemCommand does not fire

    thijs braem via .NET 247, May 15, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    184
    thijs braem via .NET 247
    May 15, 2005
  5. Krushna

    Repeater ItemCommand does not fire the first time

    Krushna, Jul 29, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    177
    Krushna
    Jul 29, 2005
Loading...

Share This Page