Home All Groups Group Topic Archive Search About

Filling a data grid with a Datareader

Author
6 Feb 2006 3:15 AM
Ant
Hi, I'm using a SP with one input parameter to return query results to a
Datareader. I then want to add the rows in the data reader into a data grid.

Can you 'bind'  a datareader to a data grid? If not, how would do it?

The data grid will be read only.

What is the best approach for this? Datareader? Data set? If so, how would I
return the resultant rows from the SP into a data set. I'm quite new to
ADO.NET

Many thanks in advance for any ideas
Ant

Author
6 Feb 2006 6:18 AM
Cor Ligthert [MVP]
Ant,

This newsgroup is full of people who tell that they use a stored procedure.
For AdoNet that is not so interesting (you have to use parameters, however
that you should forever).

More interesting for this question is if you use a windowforms datagrid or a
webform datagrid.

To the last you can bind the datareader to that datagrid using its
datasource and after that databind that. For the first you cannot.

I hope this helps,

Cor
Author
6 Feb 2006 7:17 AM
Ant
Hi Cor,

I'm using a Web form datagrid so i guess I can't bind it. So then, how would
I load the Datareader data into the datagrid? What methods does  the Datagrid
expose to allow me to do this?

Thanks

Show quote
"Cor Ligthert [MVP]" wrote:

> Ant,
>
> This newsgroup is full of people who tell that they use a stored procedure.
> For AdoNet that is not so interesting (you have to use parameters, however
> that you should forever).
>
> More interesting for this question is if you use a windowforms datagrid or a
> webform datagrid.
>
> To the last you can bind the datareader to that datagrid using its
> datasource and after that databind that. For the first you cannot.
>
> I hope this helps,
>
> Cor
>
>
>
Author
6 Feb 2006 7:44 AM
Cor Ligthert [MVP]
Ant,

Yes you can use to a datareader (as I tried to tell in my previous answer).

See the first sample in this article

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-pageablesortable.asp

I hope this helps,

Cor

Show quote
> Hi Cor,
>
> I'm using a Web form datagrid so i guess I can't bind it. So then, how
> would
> I load the Datareader data into the datagrid? What methods does  the
> Datagrid
> expose to allow me to do this?
>
> Thanks
>
> "Cor Ligthert [MVP]" wrote:
>
>> Ant,
>>
>> This newsgroup is full of people who tell that they use a stored
>> procedure.
>> For AdoNet that is not so interesting (you have to use parameters,
>> however
>> that you should forever).
>>
>> More interesting for this question is if you use a windowforms datagrid
>> or a
>> webform datagrid.
>>
>> To the last you can bind the datareader to that datagrid using its
>> datasource and after that databind that. For the first you cannot.
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>>
Author
6 Feb 2006 9:28 AM
Ant
Thanks very much for your help Cor,
Ant

Show quote
"Cor Ligthert [MVP]" wrote:

> Ant,
>
> Yes you can use to a datareader (as I tried to tell in my previous answer).
>
> See the first sample in this article
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-pageablesortable.asp
>
> I hope this helps,
>
> Cor
>
> > Hi Cor,
> >
> > I'm using a Web form datagrid so i guess I can't bind it. So then, how
> > would
> > I load the Datareader data into the datagrid? What methods does  the
> > Datagrid
> > expose to allow me to do this?
> >
> > Thanks
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> Ant,
> >>
> >> This newsgroup is full of people who tell that they use a stored
> >> procedure.
> >> For AdoNet that is not so interesting (you have to use parameters,
> >> however
> >> that you should forever).
> >>
> >> More interesting for this question is if you use a windowforms datagrid
> >> or a
> >> webform datagrid.
> >>
> >> To the last you can bind the datareader to that datagrid using its
> >> datasource and after that databind that. For the first you cannot.
> >>
> >> I hope this helps,
> >>
> >> Cor
> >>
> >>
> >>
>
>
>

AddThis Social Bookmark Button