Dynamically created Linkbutton onclick not working...

S

Sheryl Landon

Hi all - I'm creating a link button at runtime, and putting in a table cell,
and then trying to hook up the click event handler... but it's not working.
Here's the code, any idea what might be wrong? Thanks!!! Sheryl

private void AddTopicToTable(dsPersonnelDevelopment m_dsPD)

{

.... other stuff

btnAddTraining = new System.Web.UI.WebControls.LinkButton();

btnAddTraining.CssClass="Button";

btnAddTraining.Text= "Insert New Training";

btnAddTraining.ID="btnAddTraining";

oCell.Controls.Add(btnAddTraining);

btnAddTraining.Click += new System.EventHandler(this.btnAddTraining_Click);

}

public void btnAddTraining_Click(object sender, System.EventArgs e)

{

}
 
B

Brock Allen

Any dynamically created controls need t be recreated upon postback. If this
code is in your page class, then this is typically done in Page_Init (but
can be done elsewhere).
 
S

Sheryl Landon

OMG, duh, thanks!

Brock Allen said:
Any dynamically created controls need t be recreated upon postback. If
this code is in your page class, then this is typically done in Page_Init
(but can be done elsewhere).
 

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
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top