新手求救,在用FormView的时候发生了这样一个奇怪的问题,我在InsertItemTemplate内写了一个TextBox控件,然后默认的text值比如是'aaa'
<InsertItemTemplate>
tb_PName: <asp:TextBox ID="tb_PNameTextBox1" runat="server" Text=aaa>
</asp:TextBox
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="插入">
</asp:LinkButton>
</InsertItemTemplate>然后点插入的时候启动了FormView1_ItemInserting事件,我在事件里面打算获取输入的TEXTBOX控件的值,比如我输入的值是'bbb'。
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
{
string tempstr= ((TextBox)this.FormView1.FindControl("tb_PNameTextBox1"));
Response.Write(tempstr);
Response.End();
}最后我发现tempstr变量的值是默认生成TEXTBOX控件时候的值'aaa',而不是我后来手工输入的值'bbb',请问这个是什么原因啊? 就算我在FormView1_ItemInserting事件里面加上Page.DataBind()事件,可是获取的值还是'aaa',请问在FormView里面怎么才能获取手工输入的TEXTBOX的值呢?
<InsertItemTemplate>
tb_PName: <asp:TextBox ID="tb_PNameTextBox1" runat="server" Text=aaa>
</asp:TextBox
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="插入">
</asp:LinkButton>
</InsertItemTemplate>然后点插入的时候启动了FormView1_ItemInserting事件,我在事件里面打算获取输入的TEXTBOX控件的值,比如我输入的值是'bbb'。
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
{
string tempstr= ((TextBox)this.FormView1.FindControl("tb_PNameTextBox1"));
Response.Write(tempstr);
Response.End();
}最后我发现tempstr变量的值是默认生成TEXTBOX控件时候的值'aaa',而不是我后来手工输入的值'bbb',请问这个是什么原因啊? 就算我在FormView1_ItemInserting事件里面加上Page.DataBind()事件,可是获取的值还是'aaa',请问在FormView里面怎么才能获取手工输入的TEXTBOX的值呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货