multiple items in a sinngle data grid cell

Discussion in 'Databases' started by meissnersdc, Jun 14, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have a data base table where the schema is

    idCol valCol
    1 aaaa
    1 bbbb
    1 cccc
    2 dddd
    3 eeee
    3 ffff

    A particular id might have zero, one or more entries in the table.
    For all rows, I would like to concatinate the rows for each
    id into a single data grid cell.

    ---------------------------
    | 1 | aaaa bbbb cccc |
    ---------------------------
    | 2 | dddd |
    ---------------------------
    | 3 | eeee ffff |
    ---------------------------



    Is there an easy way to do this? Maybe with GROUP BY?









    Computer Consultant - www.meissnersd.com
     
  2. A "Group By" won't help in this situation. You could make a very complicated SQL Query using a "Case" statement, but that would be pretty inefficent. What I would do in this case is change the datagrid column to templated column and then either lookup the values in the child table or use a DataRelation (better) in your dataset to display the concatenated values.

    Try this: msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspn-hierdatabinding.asp

    quote:Originally posted by meissnersdc

    I have a data base table where the schema is

    idCol valCol
    1 aaaa
    1 bbbb
    1 cccc
    2 dddd
    3 eeee
    3 ffff

    A particular id might have zero, one or more entries in the table.
    For all rows, I would like to concatinate the rows for each
    id into a single data grid cell.

    ---------------------------
    | 1 | aaaa bbbb cccc |
    ---------------------------
    | 2 | dddd |
    ---------------------------
    | 3 | eeee ffff |
    ---------------------------



    Is there an easy way to do this? Maybe with GROUP BY?









    Computer Consultant - www.meissnersd.com
    </blockquote id="quote"></font id="quote">
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page