飘过~~
批量更新吗?
看样子学号应该是唯一值
设置为DATAKEY
如果做批量更新这样用
protected void Button1_Click(object sender, EventArgs e)
{
foreach (DataGridItem i in DataGrid1.Items)
{
TextBox txt = (TextBox)i.FindControl("TextBox2");
string text = txt.Text.ToString();
string strDelId = DataGrid1.DataKeys[i.RowIndex].Value.ToString();
if (txt.Text == null)
{
Response.Write("<script defer>alert('不能为空!');</script>");
}
else
{
string str_mark = "update lab_students set mark='" + text + "' where user_ID='" + strDelId + "'";
co_m.ENQ(str_mark);
Response.Write("<script defer>alert('输入成功!');</script>");
}
}
}
你试了看看吧,我不太记得datagrid的方法了,用2005习惯了,如果出错在贴出来