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.
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.