第1个回答 2013-05-26
string a = this.GridView2.DataKeys[e.RowIndex][0].ToString();
string str = ((TextBox)this.GridView2.Rows[e.RowIndex].Cells[0].Controls[0]).Text;
string ds = ((TextBox)this.GridView2.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Test;Integrated Security=True");
con.Open();
SqlCommand cmd=new SqlCommand("update T1 set T_title='"+str+"' ,T_date='"+ds+"' where T_id='"+a+"'",con);
if (Convert.ToInt32(cmd.ExecuteNonQuery()) > 0)
{
Response.Write("更新成功");
}
else
Response.Write("更新失败");
bind();
}本回答被网友采纳