button click event not firing in PreRender of the updatepanel

M

Murthy

Hi,
i have a webpage with an updatepanel updatepanel1.
i am adding controls dynamically to the updatepanel on the prerender event.
i am using the prerender event as i want to get the latest bata from the
database which include the data i have inserted on my last button click.
But the button click event is not getting trigged on clicking the button.
Here is the sample code in PreRender

SqlCommand cmd = new SqlCommand("SELECT Heading, ID FROM tblNews ORDER BY ID
;", conn);
conn.Open();
SqlDataReader sqlData =
cmd.ExecuteReader(CommandBehavior.CloseConnection);

while (sqlData.Read())
{
lblHeading = new Label();
lblHeading.Font.Bold = true;
lblHeading.Text = sqlData.GetValue(0).ToString()+"<br/>";
News.Controls.Add(lblHeading);

btnDelete = new Button();
btnDelete.ID = sqlData.GetValue(1).ToString();
btnDelete.Style.Add("float", "right");
btnDelete.Text = "Delete";
btnDelete.Click += new EventHandler(btnDelete_Click);
News.Controls.Add(btnDelete);
}
sqlData.Close();

Can someone let me know what is the problem?
How i can overcome that problem.
 
B

Bob Barrows [MVP]

Murthy said:
Hi,
i have a webpage with an updatepanel updatepanel1.

Sorry, I have yet to use that functionality. Moreover:
There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic (COM-based) asp newsgroup.
ASP.Net bears very little resemblance to classic ASP so, while you may be
lucky enough to find a dotnet-knowledgeable person here who can answer your
question, you can eliminate the luck factor by posting your question to a
group where those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.aspnet or the forums at www.asp.net.
 

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
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top