onClick Event Not Firing
am 09.03.2007 16:57:15 von RitaGHello.
I posted this question in the C# discussion group but am posting it here
also since ASP is involved.
I'm new to C# and need some help regarding an onClick event not firing.
I have a data grid that I add a cell to programatically. The cell is a
hyperlink and the onClick is set to _doPostBack. In my code I handle the
event but when I click on that added hyperlink nothing happens.
Here's my code (I'll just show the relevant stuff).
The data grid is dgBillSummary.
In MyClass.ascx I have a hidden LinkButton:
Here's MyClass.ascx.cs
public class MyClass
protected System.Web.UI.WebControls.LinkButton lnkPostBack;
|
private void InitializeComponent()
this.lnkPostBack.Click += new System.EventHandler(this.lnkPostBack_Click);
|
private void dgBillSummary_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
|
Label lblShowAll = new Label();
lblShowAll.Text = "
onContextMenu=\"NoContextmenu();\" href=\"#ShowAll\"
onClick=\"_doPostBack('lnkPostBack','ShowAll');\"> Show All";
e.Item.Cells[0].Controls.Add(lblShowAll); // here I'm adding a cell to the
data grid
|
// Here's the onClick event code that I never get to
private void lnkPostBack_Click(object sender, System.EventArgs e)
{
|
}
Any suggestions will be greatly appreciated!
TIA,
Rita