Asp.net Gridview动态控件问题

Asp.net Gridview动态控件问题,asp.net,Asp.net,我已将Gridview设置为autogenerate columns=true我已为某些列和页脚创建了一些动态文本框现在ehn我单击页脚按钮Gridview rowcomand事件未激发,要激发此命令,我必须再次绑定Gridview,但当我绑定我的值时,文本框中的更改消失了。。 以下是我的代码行数据绑定事件 protected void grdMaterialPercentage_RowDataBound(object sender, GridViewRowEventArgs e) {

我已将Gridview设置为autogenerate columns=true我已为某些列和页脚创建了一些动态文本框现在ehn我单击页脚按钮Gridview rowcomand事件未激发,要激发此命令,我必须再次绑定Gridview,但当我绑定我的值时,文本框中的更改消失了。。 以下是我的代码行数据绑定事件

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 >= 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 >= 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++;
                }
            }
        }
    }

我建议您使用诸如Firebug之类的工具,在单击网格上的链接时,使用Javascript查看引擎盖下发生了什么。这就是我站在你的立场上所做的