PushButton v. LinkButton in a DataGrid

Discussion in 'ASP .Net' started by Mark, Jul 3, 2003.

  1. Mark

    Mark Guest

    I have two buttons in a DataGrid. If I leave the ButtonType = "LinkButton",
    the EditCommand and DeleteCommand events fire fine. If I change th
    ButtonType = "PushButton", the events do not fire. Does this buttonType
    property change how the events fire? Suggestions? I have the ItemCommand
    event wired up to, but that only fires for the LinkButton as well.

    A few code samples below ...

    Thanks!

    Mark

    *** Code - I left out the brackets intentionally as I wasn't sure if they'd
    get mangled when sent via email. ***

    ** The following will fire the EditCommand event.
    asp:ButtonColumn Text="Edit" CommandName="Edit" ButtonType="LinkButton"

    ** The following will NOT fire the EditCommand event.
    asp:ButtonColumn Text="Edit" CommandName="Edit" ButtonType="PushButton"

    this.DataGrid1.ItemCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCom
    mand);
    this.DataGrid1.EditCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCom
    mand);
    this.DataGrid1.DeleteCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteC
    ommand);
     
    Mark, Jul 3, 2003
    #1
    1. Advertising

  2. Mark

    Mark Guest

    Got it to work. I don't understand it, but it works. Below is all I
    changed:

    Old code in Page_Load:

    dgSir.DataBind();

    New Code in Page_Load:

    if (!IsPostBack)
    {
    dgSir.DataBind();
    }

    So, why would the PushButton be affected by a re-binding of the data, but
    the LinkButton wouldn't?

    Thanks.

    Mark

    "Mark" <> wrote in message
    news:...
    > I have two buttons in a DataGrid. If I leave the ButtonType =

    "LinkButton",
    > the EditCommand and DeleteCommand events fire fine. If I change th
    > ButtonType = "PushButton", the events do not fire. Does this buttonType
    > property change how the events fire? Suggestions? I have the ItemCommand
    > event wired up to, but that only fires for the LinkButton as well.
    >
    > A few code samples below ...
    >
    > Thanks!
    >
    > Mark
    >
    > *** Code - I left out the brackets intentionally as I wasn't sure if

    they'd
    > get mangled when sent via email. ***
    >
    > ** The following will fire the EditCommand event.
    > asp:ButtonColumn Text="Edit" CommandName="Edit" ButtonType="LinkButton"
    >
    > ** The following will NOT fire the EditCommand event.
    > asp:ButtonColumn Text="Edit" CommandName="Edit" ButtonType="PushButton"
    >
    > this.DataGrid1.ItemCommand += new
    >

    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCom
    > mand);
    > this.DataGrid1.EditCommand += new
    >

    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCom
    > mand);
    > this.DataGrid1.DeleteCommand += new
    >

    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteC
    > ommand);
    >
    >
     
    Mark, Jul 3, 2003
    #2
    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. Curtis Hatter

    Solving DataGrid's PushButton Problem

    Curtis Hatter, Oct 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,891
  2. Nick Gilbert
    Replies:
    2
    Views:
    915
    Jeffrey Tan[MSFT]
    Dec 15, 2003
  3. Tim Meagher
    Replies:
    6
    Views:
    2,063
    naija naija
    Oct 28, 2004
  4. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    Help on LinkButton vs PushButton ??

    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Jan 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,747
    S. Justin Gengo [MCP]
    Jan 13, 2006
  5. EricT

    LinkButton works but PushButton does not

    EricT, Apr 19, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    164
    EricT
    Apr 20, 2004
Loading...

Share This Page