473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
Feb 26 '08 #1
1 1993
On Feb 25, 7:11 pm, DanThMan <danth...@cox.netwrote:
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
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
Feb 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joey | last post by:
Hello all, I am trying to read a directory listing into a string and then use that data, along with some other data, to create HTML for display in a gridview row. A sample item in the string...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
1
by: mahalie | last post by:
I'm new to .NET and trying to develop a web application to search for and display employee information from a database based on their skills or education or staff level. The database is highly...
0
by: H5N1 | last post by:
Hi there It seems I've spotted interesting problem in a job I've got to do. I have 3 tables: meals, employees, and intersecting table: meals_for_employees with bool field meaning, that given...
3
by: tarscher | last post by:
Hi all, I have a gridview populated with data coming from a dataset (created via the wizard). The data shown in the gridview is dependent on the the choice of a control (dropdown with...
0
by: Reinhard | last post by:
Hi, Need some directions on Ajax, UpdatePanel and Gridview to achive the following: I like to show a Gridview with Data ONLY if the user is interested in Details, but without a full page...
2
by: Thammarat charoenchai. | last post by:
Hi. I'm newbie to asp.net now i can use gridview to show data from sqldatasource. But I wonder How to show lookup field data. like get parameter from querystring name "pid" (ProductID)...
4
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview that has 1 row of data. I am trying to set the values of dropdown boxes for each data row based on the data I have binded to the grid but for some reason when I use the...
1
by: dotnetnovice | last post by:
Hi everybody... I want to show data in the data gridview placed in my form after getting data from my data access layer class through a class... Here is my code in the data access layer class....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.