473,608 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 (SolidColorBrus h). 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 2013
On Feb 25, 7:11 pm, DanThMan <danth...@cox.n etwrote:
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 (SolidColorBrus h). 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
1386
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 might look like this... <div style='vertical-align:middle;'><img src='image.jpb'><a href='somefile.zip'>somefile.zip</a></div> I then bind the array to a gridview to show on the form.
37
5206
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 would you even continue to use Access as a backend when you have a much superior option in SQL express? What about as a future front-end development tool? Let's get serious. Microsoft continues to publish numerous articles and videos on how you...
1
1114
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 normalized, each record I want to display will have serveral fields that have an associated subset of data to display with them. I know how to do this the old ASP way but I can't find any tutorials that address this problem specifically. Can...
0
1591
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 employee wants a given meal. employees -----------------
3
10141
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 autopostback enabled). When I load the page for the first time I the gridview is empty. When I select something in the dropdownlist the gridview is populated correctly. I guess this has something to do with the fact that the first time no data from the...
0
3441
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 reload! If the page loads, only a summary (eg. COUNT of recs) should be displayed
2
1680
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) and show ProductName
4
4156
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 following below the rows are 0 so the foreach is skipped. gridview_RowDataBound() { foreach (GridViewRow dr in gridview.Rows) } Thanks. --
1
2802
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. public class DBHandler { public List<Programs> GetAllPrograms() {
0
8002
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8496
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8475
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8148
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6816
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1594
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.