I've got the following code as part of a C# web form but am having problems
calling a command. I create a dataset and put some data on the screen. This
works fine. (relevant sample below)
foreach (DataRow row in ds.Tables["Orders"].Rows)
{
detailsbtn = new LinkButton();
//Assign a unique ID to the details control
detailsbtn.ID = "details" + row["OrderID"].ToString().Rep lace("-",
String.Empty);
detailsbtn.Text =
DateTime.Parse( row["OrderDate"].ToString()).To ShortDateString ()+" - No.
"+row["OrderNumbe r"].ToString()+" from user " +row["UserName"].ToString();
detailsbtn.Comm andArgument = row["OrderID"].ToString();
detailsbtn.Comm and += new CommandEventHan dler(OnViewDeta ils);
// Add the controls
phOrders.Contro ls.Add(detailsb tn);
phOrders.Contro ls.Add(new LiteralControl( "<br>"));
}
I then have the following for the OnViewDetails handler. When I click one of
the LinkButtons created in the above code, this handler should be called but
it doesn't seem to be calling it. It simply posts back to the page but
doesn't set the text of the label.
private void OnViewDetails(O bject sender, CommandEventArg s e)
{
this.lblMessage .Text = "Button has been pressed";
}
As this is part of a bigger page, I've uploaded the aspx and cs files to
http://andrew-banks.co.uk/problem.zip if people need access to the full code
in order to help.
Thanks in advance,
Andrew