GridView选中行更新


 

string tb0 = GridView1.Rows[e.RowIndex].Cells[3].Text.ToString().Trim();//DataKeyNames的值autoid,cell从0开始

 string tb1 = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim();//把选择的gridview行类型转换为TextBox类型

string sql="update 表 set syncmzid=@syncmzid where autoid=487";

string con= WebConfigurationManager.AppSettings["strcon"];

SqlConnection con = new SqlConnection(con);

try{

con.open();

 SqlCommand cmd = new SqlCommand(sql, con);

int i= cmd.ExecuteNonQuery();//sql语句执行

if(true)

  {

  

  }

  

SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(ds, "data");
GridView1.DataSource = ds.Tables["data"].DefaultView;
GridView1.DataBind();

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM