DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
unwantedspam said:
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.
 
unwantedspam said:
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.
 
Back
Top