Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear my friends
I created a Gridview which was contained photo and title. I also created a linkbutton to edit the photo and title. this linkbuttton transfer the users to the second page to edit the title and photo of gridview. in new page using of programming the photo is changed but the title is not changed.
the program is :
C++
protected void Button1_Click(object sender, EventArgs e)
       {

           int id = Convert.ToInt32(Request.QueryString["Code"]);

           string filename = FileUpload1.ToolTip;
           if (FileUpload1.HasFile)
           {
               filename = FileUpload1.FileName;
               FileUpload1.SaveAs(Server.MapPath("pics\\") + filename);
           }

           SqlConnection con = new SqlConnection();
           con.ConnectionString = "Data Source=.;Initial Catalog=tbldms1;Integrated Security=True";
           string q = "update ooo set title=@title,photo=@photo,where id=@id";
           SqlCommand cmd = new SqlCommand(q, con);
           cmd.Parameters.AddWithValue("@id", id);
           cmd.Parameters.AddWithValue("@title", TextBox1.Text);
           cmd.Parameters.AddWithValue("@photo",filename);
           con.Open();
           cmd.ExecuteNonQuery();
           con.Close();
           TextBox1.Text = "";

       }

please help me
Best wishes
Posted
Updated 27-Jun-15 4:46am
v2
Comments
[no name] 27-Jun-15 11:02am    
Maybe only because TextBox1 is still in "EditMode" and does not have the currently edited value. To check this, simply press Tab to finish....
Member 11796666 27-Jun-15 11:41am    
I do not think so. But please explain your answer more for me.
[no name] 27-Jun-15 13:07pm    
It was not an answer, just a comment...a hint.

All depends a lot on the developing env. so this was/is just an assumption.
In case you edit a field, the question is when "edit" is adopted. Usually this happens if one press "enter" or one leave the edit field with e.g."Tab"

...f***ing formatting f..ucked me...sorry.
Afzaal Ahmad Zeeshan 27-Jun-15 13:14pm    
Sergey Alexandrovich Kryukov 27-Jun-15 13:57pm    
Also, you need to specify in your question what you mean by "GridView". Which one? Full type name, please.
—SA

1 solution

Steep 1 : In this query
C#
string q = "update ooo set title=@title,photo=@photo,where id=@id";

remove the coma

C#
string q = "update ooo set title=@title,photo=@photo where id=@id";


Step 2: Check what is the value in text box
C#
TextBox1.Text
 
Share this answer
 
Comments
Member 11796666 29-Jun-15 9:17am    
Dear My Friends
The Problem is solved. Thanks for your time and attentions.
Best wishes

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