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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. C# 2.0 ASP.NET Postback & ObjectDataSource

C# 2.0 ASP.NET Postback & ObjectDataSource

Scheduled Pinned Locked Moved C#
questioncsharpasp-net
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.
  • K Offline
    K Offline
    kselman
    wrote on last edited by
    #1

    I think this is an easy question.. I have a DataList displaying data from a ObjectDataSource and an input form that inserts data into the same table. Upon postback the DataList is showing the data prior to the postback. How do I refill the data on postback? Id post some code but filling of dataset and databind is "magic".. here is the code Im using in the ButtonClick function: NewsDataSetTableAdapters.CommentsTableAdapter commentsTable = new NewsDataSetTableAdapters.CommentsTableAdapter(); commentsTable.Insert(newsID, subjectTextBox.Text, commentTextBox.Text, ipAddress, DateTime.Now, emailTextBox.Text);

    C 1 Reply Last reply
    0
    • K kselman

      I think this is an easy question.. I have a DataList displaying data from a ObjectDataSource and an input form that inserts data into the same table. Upon postback the DataList is showing the data prior to the postback. How do I refill the data on postback? Id post some code but filling of dataset and databind is "magic".. here is the code Im using in the ButtonClick function: NewsDataSetTableAdapters.CommentsTableAdapter commentsTable = new NewsDataSetTableAdapters.CommentsTableAdapter(); commentsTable.Insert(newsID, subjectTextBox.Text, commentTextBox.Text, ipAddress, DateTime.Now, emailTextBox.Text);

      C Offline
      C Offline
      Christopher Duncan
      wrote on last edited by
      #2

      It's pretty common to put the code to fill the data list in the Page_Load routine, and to place it inside an if (!IsPostBack) test since normally you only need to populate the control once, when the page loads. However, if you happen to have your population code inside this test for your particular situation, it wouldn't repopulate the control on the postback because it's explicitly told not to. Don't know if this is how you have your code structured, but if it is, your fix may be as simple as moving the code outside the test so that it executes on every invocation of Page_Load, postback or not. Hope this helps...

      Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

      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