I have a gridview that is populated with data from SQL and I would like to add buttons/linkbuttons dynamically to its columns.
protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
Button button = new Button();
button.ID = "row" + e.Row.RowIndex;
button.Text = "click me";
button.Click += new EventHandler(Unnamed_Click);
e.Row.Cells[1].Controls.Add(button);
}
Visually that works fine but when clicking it, it does a postback and the changes are lost. The buttons are gone.
Where can I recreate them so they persist?