麻烦高手帮我看看这段代码,总是报错
我想把GRIDVIEW中自定义模板中textbox中填写的文本更新到数据库表中,但总是提示“无法将类型为“System.Web.UI.LiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。”
这句代码报错,麻烦高手赐教一下,谢谢!
Mydb.ExcuteUpdateQuery("update tb_defen set id = '" + Session["id"].ToString() + "',defen1 = '"
+ ((TextBox)(GridView1.Rows[i].Cells[1].Controls[0])).Text + "',defen2 = '"
+ ((TextBox)(GridView1.Rows[i].Cells[2].Controls[0])).Text + "',defen3 = '"
+ ((TextBox)(GridView1.Rows[i].Cells[3].Controls[0])).Text + "',defen4 = '"
+ ((TextBox)(GridView1.Rows[i].Cells[4].Controls[0])).Text + "',defen5 = '"
+ ((TextBox)(GridView1.Rows[i].Cells[1].Controls[0])).Text + "' where name = '" + (GridView1.Rows[i].Cells[0].Controls[0]).ToString() + "");