should I bind datagrid to array or temporary dataset?

Discussion in 'ASP .Net' started by AFN, Feb 16, 2004.

  1. AFN

    AFN Guest

    I need to manually create the data to be shown in a datagrid (or some data
    table object). Should I create an array and bind the array to the
    datagrid OR should I create a temporary dataset and bind that to the
    datagrid? I have never done either (usually I get a recordset from a
    stored procedure and bind results directly). I also don't know which is
    faster. Whichever you suggest, can you give a couple lines of sample code?
    Thank you.
    AFN, Feb 16, 2004
    #1
    1. Advertising

  2. A DataGrid has a good bit of overhead. You might want to think about using
    something leaner, such as a Repeater or DataList. The chief advantage of a
    DataGrid is paging, and if you don't need it, you might want to think about
    one of the other 2. In any case, you said "create the data" - how you
    display it depends on what kind of data it is. If, for example, you're
    querying a database to get it, you can bind to a DataReader or DataTablle,
    both of which can be populated easily from a database query. If not, again,
    what format is this data in?

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "AFN" <> wrote in message
    news:pO8Yb.4105$...
    > I need to manually create the data to be shown in a datagrid (or some data
    > table object). Should I create an array and bind the array to the
    > datagrid OR should I create a temporary dataset and bind that to the
    > datagrid? I have never done either (usually I get a recordset from a
    > stored procedure and bind results directly). I also don't know which is
    > faster. Whichever you suggest, can you give a couple lines of sample

    code?
    > Thank you.
    >
    >
    Kevin Spencer, Feb 16, 2004
    #2
    1. Advertising

  3. AFN

    AFN Guest

    Hi. For argument sake, we can say that I'll bind to a repeater. I was just
    writing "datagrid" as an example.

    I have to create the data in code. I cannot query the database. It's a
    lot of math stuff that needs to be calculated in the code's business layer,
    and then output to a table. As I create each row of data, I can store it
    in any way before outputting to the html table. I can store to an array, or
    a temporary dataset if that is better (I have not done that). Then I can
    bind that datasource to the repeater object. But how can I do this? And
    do I have to create an interface for the datasource? Or should I just
    insert rows in an html table object as I create each row of data, and forget
    data controls altogether?


    "Kevin Spencer" <> wrote in message
    news:...
    > A DataGrid has a good bit of overhead. You might want to think about using
    > something leaner, such as a Repeater or DataList. The chief advantage of a
    > DataGrid is paging, and if you don't need it, you might want to think

    about
    > one of the other 2. In any case, you said "create the data" - how you
    > display it depends on what kind of data it is. If, for example, you're
    > querying a database to get it, you can bind to a DataReader or DataTablle,
    > both of which can be populated easily from a database query. If not,

    again,
    > what format is this data in?
    >
    > --
    > HTH,
    > Kevin Spencer
    > .Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "AFN" <> wrote in message
    > news:pO8Yb.4105$...
    > > I need to manually create the data to be shown in a datagrid (or some

    data
    > > table object). Should I create an array and bind the array to the
    > > datagrid OR should I create a temporary dataset and bind that to the
    > > datagrid? I have never done either (usually I get a recordset from a
    > > stored procedure and bind results directly). I also don't know which

    is
    > > faster. Whichever you suggest, can you give a couple lines of sample

    > code?
    > > Thank you.
    > >
    > >

    >
    >
    AFN, Feb 16, 2004
    #3
  4. > do I have to create an interface for the datasource? Or should I just
    > insert rows in an html table object as I create each row of data, and

    forget
    > data controls altogether?


    That's a good question. My guess would be that unless you are planning to do
    something else with the data, just writing it out to an HtmlTable would be
    fine, and require less processing than any other solution.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "AFN" <> wrote in message
    news:xz9Yb.4116$...
    > Hi. For argument sake, we can say that I'll bind to a repeater. I was

    just
    > writing "datagrid" as an example.
    >
    > I have to create the data in code. I cannot query the database. It's a
    > lot of math stuff that needs to be calculated in the code's business

    layer,
    > and then output to a table. As I create each row of data, I can store it
    > in any way before outputting to the html table. I can store to an array,

    or
    > a temporary dataset if that is better (I have not done that). Then I can
    > bind that datasource to the repeater object. But how can I do this? And
    > do I have to create an interface for the datasource? Or should I just
    > insert rows in an html table object as I create each row of data, and

    forget
    > data controls altogether?
    >
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > A DataGrid has a good bit of overhead. You might want to think about

    using
    > > something leaner, such as a Repeater or DataList. The chief advantage of

    a
    > > DataGrid is paging, and if you don't need it, you might want to think

    > about
    > > one of the other 2. In any case, you said "create the data" - how you
    > > display it depends on what kind of data it is. If, for example, you're
    > > querying a database to get it, you can bind to a DataReader or

    DataTablle,
    > > both of which can be populated easily from a database query. If not,

    > again,
    > > what format is this data in?
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "AFN" <> wrote in message
    > > news:pO8Yb.4105$...
    > > > I need to manually create the data to be shown in a datagrid (or some

    > data
    > > > table object). Should I create an array and bind the array to the
    > > > datagrid OR should I create a temporary dataset and bind that to the
    > > > datagrid? I have never done either (usually I get a recordset from a
    > > > stored procedure and bind results directly). I also don't know which

    > is
    > > > faster. Whichever you suggest, can you give a couple lines of sample

    > > code?
    > > > Thank you.
    > > >
    > > >

    > >
    > >

    >
    >
    Kevin Spencer, Feb 16, 2004
    #4
    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. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=

    RE: bind datagrid to dataset filled at runtime

    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, Apr 8, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,592
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Apr 8, 2004
  2. Bennett Haselton
    Replies:
    2
    Views:
    14,292
    Bennett Haselton
    Oct 7, 2004
  3. Replies:
    7
    Views:
    3,203
    James Kanze
    Feb 12, 2008
  4. bill yeager

    trying to bind a typed dataset to a datagrid

    bill yeager, Sep 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    152
    bill yeager
    Sep 17, 2004
  5. Brian Potroz
    Replies:
    3
    Views:
    562
Loading...

Share This Page