How to store a datatable temporarily

Discussion in 'ASP .Net' started by Sobin Thomas, Jun 2, 2008.

  1. Sobin Thomas

    Sobin Thomas Guest

    Hi All.......
    I am a beginner in asp.net.I need your help.I have a gridview control in my
    Default.aspx page.I use data adapter to fill a datatable and then I set the
    datasource of the gridview as the datatable.The datatable obtained is a
    large one.I want this table to be in memory(I dont know how to),as I have to
    use the same datatable for enabling paging in gridview.
    In short,my problem is ,I need to store the datatable (which is filled by
    the adapetr) somewhere temporarily for further use.How can I accomplish
    this?
    Hope You'll surely have the solution
    Regards
     
    Sobin Thomas, Jun 2, 2008
    #1
    1. Advertising

  2. Hello Sobin,

    First, if you get everything from DB to DataSet/DataTable in will be stored
    in memory.
    Second, your should not extract everything from DB to you dataTables, because
    it hinders the performance
    Third, read there http://msdn.microsoft.com/en-us/library/aa479347.aspx how
    to implement paging without extracting all data from database

    ---
    WBR,
    Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo


    ST> Hi All.......
    ST> I am a beginner in asp.net.I need your help.I have a gridview
    ST> control in my
    ST> Default.aspx page.I use data adapter to fill a datatable and then I
    ST> set the
    ST> datasource of the gridview as the datatable.The datatable obtained
    ST> is a
    ST> large one.I want this table to be in memory(I dont know how to),as I
    ST> have to
    ST> use the same datatable for enabling paging in gridview.
    ST> In short,my problem is ,I need to store the datatable (which is
    ST> filled by
    ST> the adapetr) somewhere temporarily for further use.How can I
    ST> accomplish
    ST> this?
    ST> Hope You'll surely have the solution
    ST> Regards
     
    Michael Nemtsev [MVP], Jun 2, 2008
    #2
    1. Advertising

  3. ASP.NET provides a few methods of storing data:

    ViewState - ie, in the page. Not good for a large amount of data
    Cache - Application caching
    Session - Per user caching

    If you are paging small amounts of data, you can either pull it each trip or
    cache in ViewState. Once you start getting more data, you will want to use
    Cache or Session. Session is useful if the user is getting data you are
    unlikely to pull for other users. If they are examining the same data sets,
    you are better to use Cache.

    A bit of info:

    Caching:
    http://www.eggheadcafe.com/articles/20060407.asp
    Go down to caching application data for a code sample

    More specific Caching implementation
    Part I http://geekswithblogs.net/ranganh/archive/2005/12/28/64260.aspx
    Part II http://geekswithblogs.net/ranganh/archive/2005/12/28/64300.aspx


    ViewState - more an intro to how it works
    http://msdn.microsoft.com/en-us/library/ms972976.aspx

    Session - also general
    http://msdn.microsoft.com/en-us/library/ms972429.aspx

    In general, you load the data in one of two places:

    1. Page_Load in a block where IsPostBack is false
    2. After a form submit to pull data

    Either way, you isolate this so this code is not run on every hit to the
    page. If not, your paging will never work.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog
    http://gregorybeamer.spaces.live.com/lists/feed.rss

    or just read it:
    http://gregorybeamer.spaces.live.com/

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "Sobin Thomas" <> wrote in message
    news:e2Pzd%...
    > Hi All.......
    > I am a beginner in asp.net.I need your help.I have a gridview control in
    > my Default.aspx page.I use data adapter to fill a datatable and then I set
    > the datasource of the gridview as the datatable.The datatable obtained is
    > a large one.I want this table to be in memory(I dont know how to),as I
    > have to use the same datatable for enabling paging in gridview.
    > In short,my problem is ,I need to store the datatable (which is filled by
    > the adapetr) somewhere temporarily for further use.How can I accomplish
    > this?
    > Hope You'll surely have the solution
    > Regards
    >
    >
     
    Cowboy \(Gregory A. Beamer\), Jun 2, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Babe
    Replies:
    1
    Views:
    8,434
    Kevin Spencer
    Aug 15, 2003
  2. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,119
    paul.mariotti
    Sep 28, 2007
  3. =?Utf-8?B?Qmx1ZWZsb3dlcg==?=

    Casting DataTable to class inherit from DataTable

    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=, Apr 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,039
    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=
    Apr 2, 2004
  4. jg
    Replies:
    1
    Views:
    758
    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=
    Aug 17, 2004
  5. Ersin Gençtürk
    Replies:
    1
    Views:
    3,557
    Ersin Gençtürk
    Oct 6, 2004
Loading...

Share This Page