GridView and reader source

G

Guest

Hi, I can give a DataTable to gridview and in one line data are displayed
int the gridview using :
dgvEmployee.DataSource = myDataTable.;

When I use a dataReader instead, do "dgvEmployee.DataSource = myReader;",
nothing is displayed in the gridview.
Does that mean that GridView dosnt or can not bind to a data reader
Thanks for your help
 
M

Miha Markic [MVP C#]

Hi,

SalamElias said:
Hi, I can give a DataTable to gridview and in one line data are displayed
int the gridview using :
dgvEmployee.DataSource = myDataTable.;

When I use a dataReader instead, do "dgvEmployee.DataSource = myReader;",
nothing is displayed in the gridview.
Does that mean that GridView dosnt or can not bind to a data reader
Thanks for your help
I am not sure. Why don't you use SqlDataSource instead?
 
G

Guest

Thanks. I havn't used this object(sqldatasource). I need to work with
datareader because I have written a dataAccessLayer that sometimes returns a
DataReader and want to know how to bound it to Gridview.

Salam
 
K

Kevin Yu [MSFT]

Hi Salam

The DataGrid in an ASP.NET app can be bound to a DataReader to retrieve
data. However, the DataGrid in windows form does not accept a DataReader as
the data source. So what kind of project are you working on? If winform, I
think you have to make the dataAccessLayer return a DataTable or DataSet.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
G

Guest

So many thanks for all of you. I use heavily DS with DataGrid and wanted to
see if I can use the DataReader as a source for the GridView.
Kevin was very clear : Not Possible

Thanks again
 
K

Kevin Yu [MSFT]

You're welcome.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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

Top