should I bind datagrid to array or temporary dataset?

A

AFN

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.
 
K

Kevin Spencer

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.
 
A

AFN

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?
 
K

Kevin Spencer

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top