Home All Groups Group Topic Archive Search About

GridView and reader source

Author
5 Mar 2006 9:46 AM
SalamElias
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

Author
5 Mar 2006 10:07 AM
Miha Markic [MVP C#]
Hi,

"SalamElias" <eliassal@online.nospam> wrote in message
news:C3D9D826-29C3-488F-86F3-48C395E0F221@microsoft.com...
> 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?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Author
5 Mar 2006 12:55 PM
SalamElias
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

Show quote
"Miha Markic [MVP C#]" wrote:

> Hi,
>
> "SalamElias" <eliassal@online.nospam> wrote in message
> news:C3D9D826-29C3-488F-86F3-48C395E0F221@microsoft.com...
> > 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?
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
>
>
Author
6 Mar 2006 2:46 AM
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."
Author
6 Mar 2006 6:18 AM
Cor Ligthert [MVP]
SalamElias,

Are you using the DataBind after adding the datasource?

http://msdn2.microsoft.com/en-us/library/fkx0cy6d.aspx

I hope this helps,

Cor
Author
11 Mar 2006 6:21 AM
SalamElias
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

Show quote
"Cor Ligthert [MVP]" wrote:

> SalamElias,
>
> Are you using the DataBind after adding the datasource?
>
> http://msdn2.microsoft.com/en-us/library/fkx0cy6d.aspx
>
> I hope this helps,
>
> Cor
>
>
>
Author
14 Mar 2006 2:22 AM
Kevin Yu [MSFT]
You're welcome.

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

AddThis Social Bookmark Button