我在前台定义一个FooterTemolate
<Columns>
<asp:TemplateField HeaderText="用户名">
<FooterTemplate>
<asp:TextBox ID="txtAddTypeName" runat="server" MaxLength="50"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("UserName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
在后台获取文本框控件:TextBox addUserName = this.gv1.FooterRow.FindControl("txtAddTypeName") as TextBox;
addUserName.Text=“字符串”;
然后执行一个插入语句。。为什么插入的是空值。(SQL语句没错误)
<Columns>
<asp:TemplateField HeaderText="用户名">
<FooterTemplate>
<asp:TextBox ID="txtAddTypeName" runat="server" MaxLength="50"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("UserName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
在后台获取文本框控件:TextBox addUserName = this.gv1.FooterRow.FindControl("txtAddTypeName") as TextBox;
addUserName.Text=“字符串”;
然后执行一个插入语句。。为什么插入的是空值。(SQL语句没错误)
if(addUserName !=null) //单步调试
{
addUserName.Text="字符串";
}
if(!this.IsPostBack)