.aspx
<asp:TemplateColumn HeaderText= "余额 ">
<ItemTemplate>
<asp:Label runat= "server " Text= ' <%# DataBinder.Eval(Container, "DataItem.Balance ") %> '>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat= "server " ID= "Balance " Width= "60 " Text= ' <%# DataBinder.Eval(Container, "DataItem.Balance ") %> '>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
.cs
private void Datagrid1_UpdateCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string temp2= ((TextBox) e.Item.FindControl( "Balance ")).Text.Trim();
}
temp2的值始终为0,
------解决方案--------------------------------------------------------
在Page_Load中加上
if(!IsPostBack)
------解决方案--------------------------------------------------------
page_load中加上 if(!this.IsPostBack){ //然后绑定}
------解决方案--------------------------------------------------------
page_load里
if(!IsPostBack)
{
//你的初始化代码
}
------解决方案--------------------------------------------------------
这样呢?
string temp2= Reqeust.Params[((TextBox) e.Item.FindControl( "Balance ")).UniqueID];