LinkButton not accessing EventArg

312 Views Asked by At

I am using c#.net.

I am trying to create a LinkButton within the code-behind, when I debug my code I recieve no errors, however its not accessing the EventArg attached to the button, it does however refresh the page. What am I doing wrong?

Button Code

LinkButton myLinkButton = new LinkButton();
myLinkButton.ID = appointment.appID.ToString();
myLinkButton.CommandArgument = appointment.appID.ToString();
myLinkButton.Command += new CommandEventHandler(ViewClick);
myLinkButton.CommandName = appointment.appID.ToString();
myLinkButton.Text = appointment.contactName

Used to style button

string divLook = "height:" + divHeight + "em";

Button is then added to a panel

Panel p = new Panel();
p.Style.Add("linkStyle", divLook);
p.CssClass = "standardLink";
p.Controls.Add(myLinkButton);
dataCell.Controls.Add(p);  



protected void ViewClick(object sender, CommandEventArgs e)
{
      var appointmentId = Convert.ToInt32(e.CommandArgument);
      Debug.Write("Are you even getting in here");
}

Thanks in advance for any help.

Clare

1

There are 1 best solutions below

2
On

Everything looks legit. I would recommend viewing the source of the generated page and looking at the ID that the link button is getting. It may be duped on the page.