Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Will this work? Trying to show relational data in a GridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DanThMan - 26 Feb 2008 03:11 GMT
Hi All,

Here's how my data looks. Two tables. The first has all the data in
"expanded" form, the second has just "ID" data in "pivoted" form.

Here's the "expanded" table:

DataID | RowID | ColumnID | Label | Color
---------------------------------------------
1 | 1 | 1 | Warning | Red
2 | 1 | 2 | Caution | Yellow
3 | 1 | 3 | Warning | Red
4 | 1 | 4 | Note | Green
5 | 1 | 5 | Warning | Red
...
11 | 3 | 1 | Warning | Red
...
50 | 1 | 2 | Note | Green
---------------------------------------------

Here's the "pivoted" table (the data is pivoted on "ColumnID" so that
each cell contains a DataID)

RowID | ColumnID_1 | ColumnID_2 | ColumnID_3| ColumnID_4| ColumnID_5
---------------------------------------------
1 | 1 | 2 | 3 | 4 | 5
2 | 6 | 7 | 8 | 9 | 10
3 | 11 | 12 | 13 | 14 | 15
....
10 | 46 | 47 | 48 | 49 | 50
---------------------------------------------

Now, I want to create a GridView in XAML that looks like the "pivoted"
table but, instead of showing a DataID in each cell, it looks up the
DataID in the "expanded" table and uses the Label value instead.
Similarly, it should set the text color (Foreground) of the cell by
looking up the DataID in the "expanded" table and using the Color
value. (Note: this is a simplified example...my real situation has
even more columns that I want to use to style the cells.)

What I thought I could do was create two type converters: one that
converts from DataID (int) to Label (string), and another that
converts from the DataID (int) to Color (SolidColorBrush). Then I
could build a custom template with a TextBox/Label/TextBlock where
Text = Label and Foreground = Color.

Before I go down the road of trying to get this all to work...

* Is there an easier way (or a better way)?
* If not, do you think my idea could work?

There doesn't seem to be any built in support for pivot tables in WPF,
but I really need my data in this format.

Thanks in advance for your help!

-Dan
DanThMan - 27 Feb 2008 23:31 GMT
> Hi All,
>
[quoted text clipped - 53 lines]
>
> -Dan

In case anyone ever comes across this thread and wants to know what
happened...I gave this "converter" strategy a try and it *does* work.

-Dan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.