title: Updated row is not working in gridview in c#
body: <p>I have been created student details page.</p>
  
  <p>Here is my code for update:</p>
  
  <pre><code>protected void btnsub_Click(object sender, EventArgs e)
          {
              SqlConnection con = Connection.DBconnection();
              if (Textid.Text.Trim().Length &gt; 0)
              {
                  SqlCommand com = new SqlCommand("sp_updatestudentdetail", con);
                  com.CommandType = CommandType.StoredProcedure;
                  com.Parameters.AddWithValue("@id", Textid.Text.Trim());
                  com.Parameters.AddWithValue("@Name", Textusername.Text.Trim());
                  com.Parameters.AddWithValue("@Class", Textclass.Text.Trim());
                  com.Parameters.AddWithValue("@Section", Textsection.Text.Trim());
                  com.Parameters.AddWithValue("@Address", Textaddress.Text.Trim());
                  com.Parameters.AddWithValue("@Email", Textemail.Text.Trim());
                  com.Parameters.AddWithValue("@Mobilenum", Textmobilenum.Text.Trim());
                  com.Parameters.AddWithValue("@EC_id", Textcurricular.SelectedValue);
  
                  try
                  {
                      string filename = Image1.ImageUrl.Substring(Image1.ImageUrl.IndexOf('/')+1);
                      string[] files = Directory.GetFiles(Server.MapPath("~/Images"));
                      foreach (string f in files) File.Delete(f);
                      if (fileupload.PostedFile.FileName.Length &gt; 0)
                      {      
                          filename = Path.GetFileName(fileupload.PostedFile.FileName);
                          string fileExtension = Path.GetExtension(filename).ToLower();
                          string uniqueFileName = Guid.NewGuid().ToString() + fileExtension;
                          fileupload.SaveAs(Server.MapPath("~/Images/" + uniqueFileName));
  
                          com.Parameters.AddWithValue("@Image", (filename.Length &gt; 0) ? "Images/" + uniqueFileName : string.Empty);
                      }                    
                      com.ExecuteNonQuery();                    
                  }
                  catch (Exception ex)
                  {
                      btnsub.Text = ex.Message;
                  }
  
                      Response.Redirect("studententry.aspx");
              }
  </code></pre>
  
  <p>The insertion works fine., when i edit the row from gridview and doing some changes and update, the updated row is not working.</p>
  
  <p>After insertion the row in grid view like this: <a href="http://s17.postimg.org/kfim4buvj/image.jpg" rel="nofollow">screenshot-1</a></p>
  
  <p>after edit and update the row same in gridview like this: <a href="http://s17.postimg.org/k7zklk9an/image.jpg" rel="nofollow">screenshot-2</a></p>
  
  <p>so what is my mistake in my update code?</p>
  
  <p>Can anyone guide me to fix this?</p>
  
  <p>Thanks,</p>