Home All Groups Group Topic Archive Search About
Author
28 Dec 2005 5:16 PM
unwantedspam
Hello,
I have a Datareader with 2 fields from the database in it. I would like

to use the DataGrid to display them. This I can do. If the DataReader
has 4 rows in it I would like to display the records in 2 DataGrid
rows. So I would have the following:


ColHeader1    ColHeader2    ColHeader1    ColHeader2
Field1(0)        Field2(0)         Field1(1)        Field2(1)
Field1(2)        Field2(2)         Field1(3)        Field2(3)


Is this possible with the DataGrid? If so could you please point me in
the right direction? I have tried everything I can think of.


Thanks

Author
28 Dec 2005 7:10 PM
Rob Schieber
unwantedspam wrote:
Show quoteHide quote
> Hello,
> I have a Datareader with 2 fields from the database in it. I would like
>
> to use the DataGrid to display them. This I can do. If the DataReader
> has 4 rows in it I would like to display the records in 2 DataGrid
> rows. So I would have the following:
>
>
> ColHeader1    ColHeader2    ColHeader1    ColHeader2
> Field1(0)        Field2(0)         Field1(1)        Field2(1)
> Field1(2)        Field2(2)         Field1(3)        Field2(3)
>
>
> Is this possible with the DataGrid? If so could you please point me in
> the right direction? I have tried everything I can think of.
>
>
> Thanks
>

Its possible but not so simple,  for each datagrid item you'll need to
handle the OnItemDataBound event, then customise your field in the event
handler.

--
Rob Schieber
Are all your drivers up to date? click for free checkup

Author
28 Dec 2005 8:44 PM
unwantedspam
Thanks for you reply.

Would it be easier with a repeater?
Author
28 Dec 2005 9:01 PM
Rob Schieber
unwantedspam wrote:
> Thanks for you reply.
>
> Would it be easier with a repeater?
>

The difficulty is in the fact that you are essentially trying to
override the default databinding behavior.  This will require that in
the OnItemDataBound event you cast the appropriate value in e.Item.Data
item, and change the appropriate text in your datagridItem Cell.  It
shouldn't be too hard if you are familliar w/ the datagrid control.

--
Rob Schieber

Bookmark and Share