我没那多分哎! 以后卖身给
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
// 点更新处理事件
{
string str = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
// 比如说在这行的某个编辑框里输入新值, 点更新后调用这个事件,我要得到这个编辑筐的行值,可是/为什么是以前的呢
this.dataSet.Tables["user_info"].Rows[e.Item.ItemIndex][2] = str;
this.dataSet.AcceptChanges();
this.dataAdapter.Update(dataSet,"user_info");
this.DataGrid1.EditItemIndex = -1;
this.DataGrid1.DataSource = dataSet.Tables["user_info"];
this.DataGrid1.DataBind();
}
结果是根本不能更新,还是本来的值
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
// 点更新处理事件
{
string str = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
// 比如说在这行的某个编辑框里输入新值, 点更新后调用这个事件,我要得到这个编辑筐的行值,可是/为什么是以前的呢
this.dataSet.Tables["user_info"].Rows[e.Item.ItemIndex][2] = str;
this.dataSet.AcceptChanges();
this.dataAdapter.Update(dataSet,"user_info");
this.DataGrid1.EditItemIndex = -1;
this.DataGrid1.DataSource = dataSet.Tables["user_info"];
this.DataGrid1.DataBind();
}
结果是根本不能更新,还是本来的值
{
string update="update ClassStu set 姓名='";
where 学号=";update+=this.textBox学号.Text+" ;
this.sqlCommand1.CommandText =update;
this.sqlCommand1.Connection=this.strCon;
this.strCon.Open ();
this.sqlCommand1.ExecuteNonQuery ();
this.strCon.Close ();
this.mydataSet1.Clear ();
this.mydataAdapter.Fill (this.mydataSet1,"ClassStu");
// this.dataGrid1 .CurrentRowIndex =this.mydataSet1.Tables ["ClassStu"].Rows .Count-1;
MessageBox.Show ("修改数据成功!","Information",MessageBoxButtons.OK ,MessageBoxIcon.Information );}
catch(Exception error)
{
MessageBox.Show ("修改信息发生错误:"+ error.Message ,"提示",MessageBoxButtons.OK ,MessageBoxIcon.Information );
if(this.strCon.State==ConnectionState.Open )
{
this.strCon.Close ();
}
}
this.dataAdapter.Update(dataSet,"user_info");
this.dataSet.AcceptChanges();
DataGridItem item = (DataGridItem)((Button)source).Parent.Parent;
TextBox tb = (TextBox)item.FindControl("txtNewReply");
改为:
string str = ((TextBox)e.Item.FindControl("你的文件框ID")).Text.Trim();
应该加
if(!Page.IsPostBack)
{
}
======================================================
欢迎加入群:13817403
本人大四,这学期找工作了,各位兄弟帮帮忙
我的简历:http://sme.dlut.org/winal/introduce.aspx
======================================================