G
Guest
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:
<asp:LinkButton id="lnkPostBack" runat="server" Height="1px"
Visible="False">PostBack</asp: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 = "<a name=\"#ShowAll\" class=\"HypLink\"
onContextMenu=\"NoContextmenu();\" href=\"#ShowAll\"
onClick=\"_doPostBack('lnkPostBack','ShowAll');\"> Show All</a>";
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
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:
<asp:LinkButton id="lnkPostBack" runat="server" Height="1px"
Visible="False">PostBack</asp: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 = "<a name=\"#ShowAll\" class=\"HypLink\"
onContextMenu=\"NoContextmenu();\" href=\"#ShowAll\"
onClick=\"_doPostBack('lnkPostBack','ShowAll');\"> Show All</a>";
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