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. TextBox in Gridview retaining old value

TextBox in Gridview retaining old value

Scheduled Pinned Locked Moved ASP.NET
questionhelp
5 Posts 3 Posters 1 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.
  • D Offline
    D Offline
    dreamaway820
    wrote on last edited by
    #1

    I am making an editable Gridview and it gets filled with data. When I click my Edit button I have some textboxes that are populated with the "old" data. I type in "new" different data. I have a line of code like this: TextBox txtUpdateHours = (TextBox)gvwDetails.Rows[e.RowIndex].FindControl("txtHours"); string newHours = txtUpdateHours.Text; However the newHours variable is always the "old" value, not what I just typed in. How can I get the "new" value? I know it must be simple but I am trouble finding what I need. Thanks for any help.

    P 1 Reply Last reply
    0
    • D dreamaway820

      I am making an editable Gridview and it gets filled with data. When I click my Edit button I have some textboxes that are populated with the "old" data. I type in "new" different data. I have a line of code like this: TextBox txtUpdateHours = (TextBox)gvwDetails.Rows[e.RowIndex].FindControl("txtHours"); string newHours = txtUpdateHours.Text; However the newHours variable is always the "old" value, not what I just typed in. How can I get the "new" value? I know it must be simple but I am trouble finding what I need. Thanks for any help.

      P Offline
      P Offline
      padmanabhan N
      wrote on last edited by
      #2

      rebind your grid data source after updating.

      Padmanabhan

      D 1 Reply Last reply
      0
      • P padmanabhan N

        rebind your grid data source after updating.

        Padmanabhan

        D Offline
        D Offline
        dreamaway820
        wrote on last edited by
        #3

        Thank you for the response. I'm not sure this will help my problem because it seems to be occuring *before* the update...I set breakpoints on the Update function and I can see it is updating with the original values, not what I just typed in the textbox. No matter what I type in the textbox it retains the original values from the data source and I'd like the Update to use what I just typed in. I'm not sure why it's doing this.

        H 1 Reply Last reply
        0
        • D dreamaway820

          Thank you for the response. I'm not sure this will help my problem because it seems to be occuring *before* the update...I set breakpoints on the Update function and I can see it is updating with the original values, not what I just typed in the textbox. No matter what I type in the textbox it retains the original values from the data source and I'd like the Update to use what I just typed in. I'm not sure why it's doing this.

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          is your code placed within if (!Page.IsPostback) ?

          In Word you can only store 2 bytes. That is why I use Writer.

          D 1 Reply Last reply
          0
          • H Herman T Instance

            is your code placed within if (!Page.IsPostback) ?

            In Word you can only store 2 bytes. That is why I use Writer.

            D Offline
            D Offline
            dreamaway820
            wrote on last edited by
            #5

            :doh: Yes that was it, thanks so much.

            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