如何绑定gridview templatefield footer文本框以插入参数?

时间:2012-05-14 19:15:32

标签: c# asp.net gridview

我有这个gridview,页脚行已启用以插入新行。但是我不知道如何在sqldatasource中将文本框与insert参数绑定。请帮帮忙?

            <asp:TemplateField HeaderText="Region Name" SortExpression="regionName">
                <FooterTemplate>
                      <asp:TextBox ID="tbInsert" runat="server" Text="" ></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>

1 个答案:

答案 0 :(得分:1)

知道了,在代码背后做了:

        if (e.CommandName == "Insert")
        {
            TextBox tbInsert = grv_regionManagement.FooterRow.FindControl("tbInsert") as TextBox;
            sds_regions.InsertParameters["regionName"].DefaultValue = tbInsert.Text;
            sds_regions.Insert();
        }
相关问题