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

Re: GridView and reader source by Miha

Miha
Sun Mar 05 04:07:07 CST 2006

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/



Re: GridView and reader source by eliassal

eliassal
Sun Mar 05 06:55:27 CST 2006

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

"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/
>
>
>

Re: GridView and reader source by v-kevy

v-kevy
Sun Mar 05 20:46:02 CST 2006

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


Re: GridView and reader source by Cor

Cor
Mon Mar 06 00:18:56 CST 2006

SalamElias,

Are you using the DataBind after adding the datasource?

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

I hope this helps,

Cor



Re: GridView and reader source by eliassal

eliassal
Sat Mar 11 00:21:29 CST 2006

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

"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
>
>
>

Re: GridView and reader source by v-kevy

v-kevy
Mon Mar 13 20:22:28 CST 2006

You're welcome.

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