By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,763 Members | 1,641 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,763 IT Pros & Developers. It's quick & easy.

Displaying data in a datagrid

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The data doesn't have to come from a DataAdapter, but calling
dataGrid.DataBind after setting its dataSource is the only way.
"John" <an*******@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
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

Nov 18 '05 #2

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
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


Nov 18 '05 #3

P: n/a
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).
"John" <an*******@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
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" <an*******@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
> 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


Nov 18 '05 #4

P: n/a

- 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 user wrote:
*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
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message380997.htm

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.