Displaying data in a datagrid

G

Guest

Hi

What is the best way to populate a datagrid?, can you populate it row by row using a datareader or is dataAdapater.Fill then Dataset binding the only way

John
 
S

Scott M.

The data doesn't have to come from a DataAdapter, but calling
dataGrid.DataBind after setting its dataSource is the only way.


John said:
Hi,

What is the best way to populate a datagrid?, can you populate it row by
row using a datareader or is dataAdapater.Fill then Dataset binding the only
way?
 
G

Guest

What are the different ways of populating the datagrid, can I do it one row at a time.

----- Scott M. wrote: -----

The data doesn't have to come from a DataAdapter, but calling
dataGrid.DataBind after setting its dataSource is the only way.


John said:
row using a datareader or is dataAdapater.Fill then Dataset binding the only
way?
 
S

Scott M.

I answered that question already....When you set the DataGrid.DataSource
property you are telling the grid where ALL the data is that it will be
bound to. When you call DataGrid.DataBind, you are instructing the grid to
bind itself to ALL of the data. You can't do it one record at a time. This
is the only way to populate a DataGrid.

If you want that functionality, look into building an HTML table dynamically
(like the way we did it in classic ASP).
 
A

ajaymehra

- you can use a sqlcommand to write a query and retrieve the records i
a datatable or dataview and bind it to the datagrid

- you can use the dataadapter method

I think you are thinking in terms of classic ASP - do while no
rs.EOF.....rs.MoveNext

You cant do that here.
You can however have complete control over the datagrid to display wha
columns and what rows by setting the Datagrids AutoGenerateColumn
property to FALSE and using the ItemBound method to display data.

newsgroup said:
*Hi,

What is the best way to populate a datagrid?, can you populate it ro
by row using a datareader or is dataAdapater.Fill then Datase
binding the only way?

John

ajaymehr
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top