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. General Programming
  3. C#
  4. Datagrid object binding and saving back

Datagrid object binding and saving back

Scheduled Pinned Locked Moved C#
databasewpfwcfhelpquestion
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.
  • R Offline
    R Offline
    Ramkithepower
    wrote on last edited by
    #1

    Hi All, I have created an object book which is as follows public class book { public string bookname; public string bookauthor; public string bookprice; } public class books:List { } now on the load of the page i get some book details stored in the database and add them to the "books" object and also I add a empty book object to the books so which can be used by the users to add one new book. I then bind this to a datagrid on the aspx page with template columns. Books books = new Books(); books=Books.getBooks(); //also adds on blank book object dgbooks.datasource = books; dgbooks.databind(); on click of the save button i require the datasource to be type cast as books object. I am trying to do this on the click event of the save button books = (Books)dgbooks.datasource; but this is not working because the datasource is entry. Because during the postback it is wiped off. Can someone please help me to come around with this one? The above code is just a sample code.. hence please ignore the mistakes.

    Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

    K 1 Reply Last reply
    0
    • R Ramkithepower

      Hi All, I have created an object book which is as follows public class book { public string bookname; public string bookauthor; public string bookprice; } public class books:List { } now on the load of the page i get some book details stored in the database and add them to the "books" object and also I add a empty book object to the books so which can be used by the users to add one new book. I then bind this to a datagrid on the aspx page with template columns. Books books = new Books(); books=Books.getBooks(); //also adds on blank book object dgbooks.datasource = books; dgbooks.databind(); on click of the save button i require the datasource to be type cast as books object. I am trying to do this on the click event of the save button books = (Books)dgbooks.datasource; but this is not working because the datasource is entry. Because during the postback it is wiped off. Can someone please help me to come around with this one? The above code is just a sample code.. hence please ignore the mistakes.

      Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

      K Offline
      K Offline
      kornakar
      wrote on last edited by
      #2

      It's not "wiped out", it's just not set yet because the page is still loading. The asp.net events are a bit of a mess. You should try to get the books in the Load or LoadComplete events. And you should also check if you have EnableViewState set to false.

      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