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. problem in displaying the data in datagrid`

problem in displaying the data in datagrid`

Scheduled Pinned Locked Moved ASP.NET
databasealgorithmshelptutorial
3 Posts 3 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.
  • M Offline
    M Offline
    manikumar_gutti
    wrote on last edited by
    #1

    Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. If anyone knows the way how it should be doing please rly me. and provide an example in maintaing a datatable session variable. regards, manikanta.

    D K 2 Replies Last reply
    0
    • M manikumar_gutti

      Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. If anyone knows the way how it should be doing please rly me. and provide an example in maintaing a datatable session variable. regards, manikanta.

      D Offline
      D Offline
      Deshpande anagha
      wrote on last edited by
      #2

      This problem can be solved if u use datatable. The data that was present on the data grid just fill this data to datatable and then the new searched data will also be filled in the same datatable then bind this datatable to the grid so that the previous data will not be lost.

      1 Reply Last reply
      0
      • M manikumar_gutti

        Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. If anyone knows the way how it should be doing please rly me. and provide an example in maintaing a datatable session variable. regards, manikanta.

        K Offline
        K Offline
        ktrrzn
        wrote on last edited by
        #3

        Hi Mani, in your problem, u can save your last data in datatable variable. To use session variable,

        Session["mySearchResult"] = searchResultTable;
        searchResultGridView.DataSource = searchResultTable;
        searchResultGridView.DataBind();

        When u search new keyword and return data back from server, save it in temp table. then retrieve your previous saved table from Session. and Loop through every row again and add it into old table and re-save it to Session.

        newSearchResultTable = // new search result data from server;
         searchResultTable  = Session\["mySearchResult"\] as DataTable;    // get back from session
         foreach(DataRow row in newSearchResultTable.Rows)               // loop every rows
         {
             searchResultTable.Rows.Add(row);                            // add to existing table
         }
        
         Session\["mySearchResult"\] = searchResultTable;                  // save back and bind again
         searchResultGridView.DataSource = searchResultTable;
         searchResultGridView.DataBind();
        

        Hint: when u enable the "EnableViewState" to false, your selected info will not be avaliable from the server. Hope it works,

        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