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. DataGrid Edit Problem

DataGrid Edit Problem

Scheduled Pinned Locked Moved ASP.NET
csharpcsscomhelpquestion
3 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.
  • A Offline
    A Offline
    Anders Molin
    wrote on last edited by
    #1

    I have a DataGrid which I have bound to an arraylist with some data in, and everyone is happy... When I click on Edit, I get TextBoxes in the grid, just as expected, but when I click Update and use the following code: TextBox description = (TextBox)e.Item.Cells[0].Controls[0]; the description textbox always holds the original value, not the one I wrote before hitting Update... :confused: Any ideas? - Anders My Photos

    WDevs - The worlds first DSP, free blog space, email and more

    J 1 Reply Last reply
    0
    • A Anders Molin

      I have a DataGrid which I have bound to an arraylist with some data in, and everyone is happy... When I click on Edit, I get TextBoxes in the grid, just as expected, but when I click Update and use the following code: TextBox description = (TextBox)e.Item.Cells[0].Controls[0]; the description textbox always holds the original value, not the one I wrote before hitting Update... :confused: Any ideas? - Anders My Photos

      WDevs - The worlds first DSP, free blog space, email and more

      J Offline
      J Offline
      Jeremy Oldham
      wrote on last edited by
      #2

      Anders, When you click the update button, the datagrid is probably databinding in the page load event. Therefor, the changed value is being changed back to the original value when it databinds. If this is the case, you need to test for Page.IsPostback and if it is not a postback (meaning first page load instead of a postback), then you bind the datagrid. I hope I have made sense. If not, let me know and I can explain further. I am typing with one hand, so hopefully, I do not have too many typos. Jeremy Oldham

      A 1 Reply Last reply
      0
      • J Jeremy Oldham

        Anders, When you click the update button, the datagrid is probably databinding in the page load event. Therefor, the changed value is being changed back to the original value when it databinds. If this is the case, you need to test for Page.IsPostback and if it is not a postback (meaning first page load instead of a postback), then you bind the datagrid. I hope I have made sense. If not, let me know and I can explain further. I am typing with one hand, so hopefully, I do not have too many typos. Jeremy Oldham

        A Offline
        A Offline
        Anders Molin
        wrote on last edited by
        #3

        Jeremy, What you say makes perfectly sense. It was not exactly what caused it, but almost... Doh, stupid me :-O Thanks... - Anders My Photos

        WDevs - The worlds first DSP, free blog space, email and more

        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