Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. edit a row in gridview

edit a row in gridview

Scheduled Pinned Locked Moved ASP.NET
helpsharepointdatabasedesignsecurity
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarala s
    wrote on last edited by
    #1

    hi friends,, i am trying to do edit the row in GridView .... this is the coding for updating System.Web.UI.WebControls.TextBox cName = new System.Web.UI.WebControls.TextBox(); cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); SqlConnection myConnection = new SqlConnection("Data Source=DAYAKAR\\sqlexpress; Initial Catalog=hospital;Integrated Security=true"); SqlCommand myCommand = new SqlCommand("SP_UpdatePerson", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(new SqlParameter("@Contactname", SqlDbType.VarChar, 50)); myCommand.Parameters["@Contactname"].Value = cName.Text; myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); myDataGrid.EditIndex = -1; BindData(); in this i got error in cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); so i modified as TextBox txtName = (TextBox)CustomerGrid.Rows[e.RowIndex].FindControl("txtContactName"); even i am not getting the updated value... in the textbox.... so that i can update that value in the DB... kindly help me soooon...

    S 1 Reply Last reply
    0
    • S sarala s

      hi friends,, i am trying to do edit the row in GridView .... this is the coding for updating System.Web.UI.WebControls.TextBox cName = new System.Web.UI.WebControls.TextBox(); cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); SqlConnection myConnection = new SqlConnection("Data Source=DAYAKAR\\sqlexpress; Initial Catalog=hospital;Integrated Security=true"); SqlCommand myCommand = new SqlCommand("SP_UpdatePerson", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(new SqlParameter("@Contactname", SqlDbType.VarChar, 50)); myCommand.Parameters["@Contactname"].Value = cName.Text; myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); myDataGrid.EditIndex = -1; BindData(); in this i got error in cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); so i modified as TextBox txtName = (TextBox)CustomerGrid.Rows[e.RowIndex].FindControl("txtContactName"); even i am not getting the updated value... in the textbox.... so that i can update that value in the DB... kindly help me soooon...

      S Offline
      S Offline
      Sosyopat
      wrote on last edited by
      #2

      did you make a postback control?

      S 1 Reply Last reply
      0
      • S Sosyopat

        did you make a postback control?

        S Offline
        S Offline
        sarala s
        wrote on last edited by
        #3

        No,.... but how to make it???....in gridview???...i didn;t fine that control...

        S 1 Reply Last reply
        0
        • S sarala s

          No,.... but how to make it???....in gridview???...i didn;t fine that control...

          S Offline
          S Offline
          sarala s
          wrote on last edited by
          #4

          thanks..sosyopat... i solved that issue... bye

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups