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 and DropDownList

DataGrid and DropDownList

Scheduled Pinned Locked Moved ASP.NET
question
4 Posts 4 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.
  • L Offline
    L Offline
    LoneKawboy
    wrote on last edited by
    #1

    I have a DataGrid with a ItemTemplate column that contains a DropDownList that I am dynamically adding items to via the ItemDataBound function and a DataTable. The user then selected from the drop down list for each row and then clicks a save button that posts back. Upon the post back all view state information for the drop down lists is gone. How can I maintain this information on the post back so that I know which item the user selected in each row?

    I M W 3 Replies Last reply
    0
    • L LoneKawboy

      I have a DataGrid with a ItemTemplate column that contains a DropDownList that I am dynamically adding items to via the ItemDataBound function and a DataTable. The user then selected from the drop down list for each row and then clicks a save button that posts back. Upon the post back all view state information for the drop down lists is gone. How can I maintain this information on the post back so that I know which item the user selected in each row?

      I Offline
      I Offline
      israeli
      wrote on last edited by
      #2

      Hi there, You should bound the data for your datagrid from the OnInit function instead of the OnLoad function.

      1 Reply Last reply
      0
      • L LoneKawboy

        I have a DataGrid with a ItemTemplate column that contains a DropDownList that I am dynamically adding items to via the ItemDataBound function and a DataTable. The user then selected from the drop down list for each row and then clicks a save button that posts back. Upon the post back all view state information for the drop down lists is gone. How can I maintain this information on the post back so that I know which item the user selected in each row?

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        Hi there, Do you by any chance bind data to the datagrid control every time the page is visited? Perhaps, posting a snippet of sample code may help.

        1 Reply Last reply
        0
        • L LoneKawboy

          I have a DataGrid with a ItemTemplate column that contains a DropDownList that I am dynamically adding items to via the ItemDataBound function and a DataTable. The user then selected from the drop down list for each row and then clicks a save button that posts back. Upon the post back all view state information for the drop down lists is gone. How can I maintain this information on the post back so that I know which item the user selected in each row?

          W Offline
          W Offline
          Wyxlwiis
          wrote on last edited by
          #4

          This will probably solve the problem Wrap your databinding in a if(!IsPostBack) clause

          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