Binding certain rows to certain columns in GridView?

Discussion in 'ASP .Net' started by bernard.oflynn@gmail.com, Mar 25, 2008.

  1. Guest

    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?
    , Mar 25, 2008
    #1
    1. Advertising

  2. Paul Shapiro Guest

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

    <> wrote in message
    news:...
    > 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, Mar 25, 2008
    #2
    1. Advertising

  3. bruce barker Guest

    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)


    "" 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?
    >
    bruce barker, Mar 25, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. helpful sql
    Replies:
    0
    Views:
    795
    helpful sql
    May 19, 2005
  2. J055
    Replies:
    2
    Views:
    4,347
    Steven Cheng[MSFT]
    Mar 24, 2006
  3. Replies:
    3
    Views:
    592
  4. -Steve-

    GridView Highlight Certain Rows

    -Steve-, Sep 12, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    427
    marss
    Sep 12, 2007
  5. VijayRama
    Replies:
    2
    Views:
    2,293
    Gregory A. Beamer
    Oct 12, 2009
Loading...

Share This Page