1.无法获取更新数据
if(!Page.IsPostBack)
{
this.DataGrid1.DataSource = ds.Tables[0].DefaultView;
this.DataGrid1.DataBind();
}
在数据绑定时必须注意.
2.另外的实现方式
<asp:TemplateColumn HeaderText="地方">
<ItemTemplate>
<asp:Label text='<%#DataBinder.Eval(Container.DataItem,"name")%>' Runat="server">
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt111" Text='<%#DataBinder.Eval(Container.DataItem,"name")%>' Runat="server"/>
</EditItemTemplate>
</asp:TemplateColumn>
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox txt = (TextBox)e.Item.Cells[1].FindControl("txt111");
Response.Write("<script>alert(\""+txt.Text+"\")</script>");
}