PDA

View Full Version : multiple items in a sinngle data grid cell


meissnersdc
06-14-2004, 09:25 AM
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

pjoyce
06-15-2004, 08:57 AM
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspn-hierdatabinding.asp)

[b]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">