Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

GridView RowUpdating Problem

Avatar of innocent1973
innocent1973 asked on
.NET ProgrammingASP.NET
5 Comments1 Solution253 ViewsLast Modified:
Hello Experts,
There is a problem on my commandtext string. Because it cannot find TextBox2 object.

Please help...

Regards
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SqlConnection MyNewConnection3 = new SqlConnection();
        SqlCommand MyNewQuery3 = new SqlCommand();


        MyNewConnection3.ConnectionString = "Data Source=.;Initial Catalog=FOREVER;User ID=sa;Password=1";
        MyNewConnection3.Open();
        MyNewQuery3.Connection = MyNewConnection3;

        


       
        
       


        MyNewQuery3.CommandText = "SET DATEFORMAT DMY UPDATE IAS_ALLOCATIONS" +
                 " SET [AllQty] =" + GridView2.SelectedRow.FindControl("TextBox2").GetType() +
          " WHERE AllocationID='" + GridView1.SelectedRow.Cells[1].Text.Trim() + "' " +
          "AND Barcode='" + GridView2.SelectedRow.Cells[2].Text.Trim() + "' ";


        //SqlCommand cmd = new SqlCommand(strSQL, cn);
        //cmd.CommandTimeout = 0;
        //if (cn.State == ConnectionState.Closed)
        //{
        //    cn.Open();
        //}
        MyNewQuery3.ExecuteNonQuery();
        MyNewConnection3.Close();

    }
ASKER CERTIFIED SOLUTION
Avatar of kris_per
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers