一个关于数据库更新的问题!!!
更新函数如下:
private void DataList1_UpdateCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
//其中TextBox1,TextBox2,TextBox3,TextBox4,TextBox5为DataList中控件
string strAddress = ((TextBox)e.Item.FindControl("TextBox1")).Text;//“=”号右边竟然为空,下面四个都一样,百思不得其解!请教!!!
string strCity = ((TextBox)e.Item.FindControl("TextBox2")).Text;
string strState = ((TextBox)e.Item.FindControl("TextBox3")).Text;
string strPhone = ((TextBox)e.Item.FindControl("TextBox5")).Text;
string strZip = ((TextBox)e.Item.FindControl("TextBox4")).Text;
int UpdateItemIndex = e.Item.ItemIndex;
this.dataSet11.Tables["tblUsers"].Rows[UpdateItemIndex]["Address"] = strAddress;
this.dataSet11.Tables["tblUsers"].Rows[UpdateItemIndex]["City"] = strCity;
this.dataSet11.Tables["tblUsers"].Rows[UpdateItemIndex]["State"] = strState;
this.dataSet11.Tables["tblUsers"].Rows[UpdateItemIndex]["Zip"] = strZip;
this.dataSet11.Tables["tblUsers"].Rows[UpdateItemIndex]["Phone"] = strPhone;
this.tblUsersAdap.Update(this.dataSet11);
this.DataList1.DataBind();
}