DataGrid

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
 
R

Rob Schieber

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

Rob Schieber

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top