页面代码
<InsertItemTemplate>
<table>
<tr>
<td>
收货人姓名
</td>
<td>
<asp:TextBox ID= "InsertReceiveMan " Text= " " runat= "server "> </asp:TextBox> </td>
</tr>
...
<asp:LinkButton ID= "lbnInsertPostAddress " Text= "添加 " CommandName= " " runat= "server " OnClick= "lbnInsertPostAddress_Click "> </asp:LinkButton>
cs代码:
protected void lbnInsertPostAddress_Click(object sender, EventArgs e)
{
TextBox ctl = (TextBox)FVPostAddress.FindControl( "InsertReceiveMan ");
if (ctl == null)
throw new Exception( "Cannot Find Control ");
Session[ "UserName "] = ctl.Text;
}
上述代码得不到值
但是在Page_Load里面倒是可以用FindControl得到值。FVPostAddress_ItemInserting也得不到值。
谢谢
------解决方案--------------------------------------------------------
看看这里就明白了
ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.NETDEVFX.v20.chs/cpref16/html/T_System_Web_UI_WebControls_FormView.htm
------解决方案--------------------------------------------------------
将绑定代码放在
if(!Page.IsPostBack) {
// 执行绑定
}