asp中 grideview 更新 无法获取值 解决办法
string str1 = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[7].Controls[0])).Text.ToString().Trim();来获取结果 但是不会成功 总是获取空的数据,
然后我想应该是在获取数据的时候出了点问题后来将Grideview的一个属性
EnableViewState=false 设置为假 的时候就成功获取了
下面贴一些处理代码希望对有同样问题的有点帮助(虽然貌似画蛇添足)
然后我想应该是在获取数据的时候出了点问题后来将Grideview的一个属性
EnableViewState=false 设置为假 的时候就成功获取了
下面贴一些处理代码希望对有同样问题的有点帮助(虽然貌似画蛇添足)
protected
void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{ //需要将GridView的属性EnableViewState=false string constr = ConfigurationManager.ConnectionStrings["xm_data_DataConnectionString"].ConnectionString; SqlConnection cn = new SqlConnection(constr); string str1 = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[7].Controls[0])).Text.ToString().Trim(); string strid = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[12].Controls[0])).Text.ToString().Trim(); string textcommd = "update kyhlxk set 审核提示='" + str1 + "' where id=" + Convert.ToInt32(strid); SqlCommand upcommd = new SqlCommand(textcommd, cn); cn.Open(); upcommd.ExecuteNonQuery(); cn.Close(); Label1.Text = textcommd; GridView1.EditIndex = -1;//编辑状态取消 gradeview();//是我重新填充Grideview的函数 }

浙公网安备 33010602011771号