Gridview dynamic controls problem
<p>I have Gridview set to autogenerate columns=true i have created some dynamic text boxes for some columna nd footer now ehn i click on footer button gridview rowcomand event is not fired, to fire this command i have to bind the gridview again but when i bind my values which i have changes in textboxes gone..
following is my code rowdatabound event </p>

<pre><code>protected void grdMaterialPercentage_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (grdMaterialPercentage.AutoGenerateColumns == true)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[0].Visible = false;
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[0].Visible = false;
                if (DataBinder.Eval(e.Row.DataItem, "AgentName").ToString() != string.Empty)
                {
                    int i = 0;
                    foreach (TableCell c in e.Row.Cells)
                    {
                        if (i &gt;= 3)
                        {
                            TextBox tb = new TextBox();
                            tb.Text = c.Text;
                            tb.ID = "txtbox" + i.ToString();
                            tb.Style.Add("Width", "25px");
                            tb.Style.Add("Height", "15px");
                            c.Controls.Clear();
                            c.Controls.Add(tb);

                        }
                        i++;
                    }
                }
                else
                {
                    e.Row.Visible = false;
                }
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Visible = false;
                int j = 0;
                foreach (TableCell c in e.Row.Cells)
                {

                    if (j &gt;= 3)
                    {
                        DataRow dr = dt.Rows[dt.Rows.Count - 1];
                        LinkButton btn = new LinkButton();

                        btn.ID = "FooterButton" + j.ToString();

                        btn.CommandName = j.ToString();
                        btn.Text = "Save" + dr[j - 1].ToString();
                        btn.CssClass = "button";
                        btn.Style.Add("align", "center");
                        btn.CommandArgument = dr[j - 1].ToString();
                        btn.OnClientClick = "return ValidateTotalPercentage('" + j + "')";
                        c.Controls.Clear();
                        c.Controls.Add(btn);

                    } j++;
                }
            }
        }
    }
</code></pre>
