GridView更新错误 [英] Gridview updating error
本文介绍了GridView更新错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox Sno = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtSno");
TextBox Name = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
TextBox Age = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtage");
TextBox Address = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtaddress");
con.Open();
SqlCommand cmd = new SqlCommand("update Details set Name = '" + Name + "',Age=" + Age + " where Sno=" + Sno, con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
}
当我运行并单击更新时,将发生以下错误;
数字名称"System.Web.UI.WebControls"包含的前缀数量超过最大数量.最大值为3.
从上面的代码中有什么问题.请帮助我.
when i run and click the update the error occurs as follows;
The number name ''System.Web.UI.WebControls'' contains more than the maximum number of prefixes. The maximum is 3.
from the above code what is the problem.please help me.
推荐答案
我不知道这是否是一个错字,但查询不应该像这样:
I don''t know if thats a typo but shouldn''t the query look like this:
con.Open();
SqlCommand cmd = new SqlCommand("update Details set Name = '" + Name.Text + "',Age=" + Age.Text + " where Sno=" + Sno.Text, con);
cmd.ExecuteNonQuery();
con.Close();
???
???
这篇关于GridView更新错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文