Binding certain rows to certain columns in GridView?

B

bernard.oflynn

I'm not sure if there is a way to do this...I have data coming back in
rows for various currencies. I need to split out the data in a
GridView so that all the rows for one currency appears in that
currency's column, i.e.
item 1 through 4 are EUR, item 5 through 8 are GBP, etc. etc.
EUR GBP USD
item1 100
item 2 200
item 3 300
item 4 500
item 5 250
item 6 450
item 7 870
item 8 890
item 9 106
item 10 115 etc.

I also need to remove a column if there are no entries for that
currency, i.e. if no data comes back for EUR then I must hide the EUR
column.

Is there an easier way to do this than on the rowdatabind event
looping through each column checking each time and working out what
cell to put data into? Is there a way to bind a column to a fieldname
and a currency and not just the fieldname?
 
P

Paul Shapiro

If the data is coming from a db, adjust the sql to produce the results you
want.
 
B

bruce barker

normally you'd pivot the data first, then display nulls as blank (simple
formatter). you can pivot in the original query, or google ado.net pivot for
sample code. you can easily create a new datatable, and pivot the rows.

-- bruce (sqlwork.com)
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top