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 disappear on postback

datagrid disappear on postback

Scheduled Pinned Locked Moved ASP.NET
helpcsharpcssasp-nettutorial
2 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.
  • L Offline
    L Offline
    lxhan
    wrote on last edited by
    #1

    I'm having a problem with a datagrid in asp.net. The datagrid loads okay, but during a postback it loses its data, for example when a button is clicked. I'm rebinding the datagrid in the page_load section, for ex: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If (Page.IsPostBack) Then dgridAnswers.DataSource = Session("svRsltTable") dgridAnswers.DataBind() End If The first time I bind the grid is in a function, for ex: Session("svRsltTable") = dSetAnsCmntQt.Tables("RsltTable") dgridAnswers.DataSource = Session("svRsltTable") dgridAnswers.DataBind() I load the session variable in this function so I can use it in the Page_load section to rebind it later. The columns is set to autoGenerateColumns =False. Thanks for any help.

    M 1 Reply Last reply
    0
    • L lxhan

      I'm having a problem with a datagrid in asp.net. The datagrid loads okay, but during a postback it loses its data, for example when a button is clicked. I'm rebinding the datagrid in the page_load section, for ex: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If (Page.IsPostBack) Then dgridAnswers.DataSource = Session("svRsltTable") dgridAnswers.DataBind() End If The first time I bind the grid is in a function, for ex: Session("svRsltTable") = dSetAnsCmntQt.Tables("RsltTable") dgridAnswers.DataSource = Session("svRsltTable") dgridAnswers.DataBind() I load the session variable in this function so I can use it in the Page_load section to rebind it later. The columns is set to autoGenerateColumns =False. Thanks for any help.

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

      Basically, if you disable ViewState of the DataGrid control, you then have to bind data in every post to the server. Otherwise, you only need to do the binding for the first time in order for data in the datagrid is not overwritten.

      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