PushButton v. LinkButton in a DataGrid

M

Mark

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);
 
M

Mark

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top