protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{//更新
string sqlstr = "update news set title='"
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "'where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlCommand sqlcom = new SqlCommand(sqlstr,conn);
conn.Open();
sqlcom.ExecuteNonQuery();
conn.Close();
GridView1.EditIndex = -1;
bind();
}
{//更新
string sqlstr = "update news set title='"
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "'where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlCommand sqlcom = new SqlCommand(sqlstr,conn);
conn.Open();
sqlcom.ExecuteNonQuery();
conn.Close();
GridView1.EditIndex = -1;
bind();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货