title: Asp.net dynamic gridview buttons
body: <p>I have a gridview that is populated with data from SQL and I would like to add buttons/linkbuttons dynamically to its columns.</p>
  
  <pre><code>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);
          }
  </code></pre>
  
  <p>Visually that works fine but when clicking it, it does a postback and the changes are lost. The buttons are gone.</p>
  
  <p>Where can I recreate them so they persist?</p>