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

Re: Filling a data grid with a Datareader by Cor

Cor
Mon Feb 06 00:18:39 CST 2006

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



Re: Filling a data grid with a Datareader by Ant

Ant
Mon Feb 06 01:17:27 CST 2006

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

Re: Filling a data grid with a Datareader by Cor

Cor
Mon Feb 06 01:44:02 CST 2006

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



Re: Filling a data grid with a Datareader by Ant

Ant
Mon Feb 06 03:28:26 CST 2006

Thanks very much for your help Cor,
Ant

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