Tuesday, March 13, 2012

should I bind datagrid to array or temporary dataset?

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.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" <DELETEnewsgroupCAPSaccount@.yahoo.com> wrote in message
news:PO8Yb.4105$Le2.286@.twister.socal.rr.com...
> 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.
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" <kevin@.takempis.com> wrote in message
news:ORs2YdM9DHA.400@.tk2msftngp13.phx.gbl...
> 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" <DELETEnewsgroupCAPSaccount@.yahoo.com> wrote in message
> news:PO8Yb.4105$Le2.286@.twister.socal.rr.com...
> > 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.
> 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" <DELETEnewsgroupCAPSaccount@.yahoo.com> wrote in message
news:xz9Yb.4116$Le2.474@.twister.socal.rr.com...
> 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" <kevin@.takempis.com> wrote in message
> news:ORs2YdM9DHA.400@.tk2msftngp13.phx.gbl...
> > 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" <DELETEnewsgroupCAPSaccount@.yahoo.com> wrote in message
> > news:PO8Yb.4105$Le2.286@.twister.socal.rr.com...
> > > 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.
> >

0 comments:

Post a Comment