Binding certain rows to certain columns in GridView?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bernard.oflynn@gmail.com

    Binding certain rows to certain columns in GridView?

    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?
  • Paul Shapiro

    #2
    Re: Binding certain rows to certain columns in GridView?

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

    <bernard.oflynn @gmail.comwrote in message
    news:80a63361-da36-4905-82cd-9086e0b18efa@s8 g2000prg.google groups.com...
    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?

    Comment

    • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

      #3
      RE: Binding certain rows to certain columns in GridView?

      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)


      "bernard.oflynn @gmail.com" wrote:
      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?
      >

      Comment

      Working...