Click here to Skip to main content
15,904,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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;
      }


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.
Posted
Updated 30-Nov-12 0:37am
v2

1 solution

I don't know if thats a typo but shouldn't the query look like this:

C#
con.Open();
SqlCommand cmd = new SqlCommand("update Details set Name = '" + Name.Text + "',Age=" + Age.Text + " where Sno=" + Sno.Text, con);
cmd.ExecuteNonQuery();
con.Close();

???
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900