473,698 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Component | Displaying columns of a DataSet as Rows in a DataGrid ?

Hi...
I'm working on a tool for editing text resources for a family of software
product my company produces.

These text resources are found in a SQL Server database, in a table called
"Resource" with the following structure :
Resource{[id],en,fr,es}
Yes.. these are the only languages supported actually.

A couple of rows in that table would look like this :
id | en | fr | es |
0000001 | Open |Ouvrir | Abrir |
0000002 | Close | Fermer | Cerrar |
etc...

I have a DataSet object, that I have filled with a SqlDataAdapter,
therefore, the first table of my Dataset is called "Resource" and has
exactly the same structure than the Table in the database.

I have a ListBox component that uses this DataSet as its DataSource. Its
DataMember property is the "Resource" table and its display member depends
on which is the primary display language that the user has chosen.

So the typical display of this listbox, if the user has chosen 'en' would be
:
Open
Close
.....

Then, when a user selects one of the list items, I use the selected row to
fill a DataGrid component in order to allow the user to edit all language
versions of the resource in a DataGrid.

Now here comes my problem. If I use a filtered version of this DataSet as
the DataSource of my DataGrid (for example a DataViewManager ), the grid will
have exactly the same look than the table I have shown above. That doesn't
work for me, cause some resources could be very long error messages,
therefore, I would like to show each column of the table as a row in the
datagrid, something like this (assuming that I have chosen the item 0000001
Language | Value
en | Close
fr | Fermer
es | Cerrar

As for now, I have manually done this transformation by creating a table
called "ResourceIt em" in the DataSource bounded to my DataGrid which I fill
by looping on the columns of the selected row. Here's a sample :

foreach(DataCol umn col in drSelectedRow.T ables["Resource"].Columns){
DataRow newGridRow = dsGridDataSet.T ables["ResourceIt em"].Rows.NewRow();
newGridRow["Language"] = col.ColumnName;
newGridRow["Value"] = drSelectedRow[col].ToString();
dsGridDataSet.A dd(newGridRow);
}

I don't like this solution 'cause it's finally not a matter of datastructure
but a matter of display. I just would like to be able to show the columns of
my original DataSet as rows in my DataGrid. Any idea how can I achieve that
?

Thanxs,

Diego

P.S. : I'm aware of the cool ways to manage Globalization in .Net and
resource files, but this is not my question. The purpose of my tool is to
edit resource files for legacy software programmed in VB6 or in ASP 4.0. So
the edition of resources is to be done with this tool I'm working on in C#
but the edited resource files are intended to be used by other older
software.


Nov 15 '05 #1
3 2544
Hi Diego,

I think as your users will be editing the resources row-by-row, you don't
need the DataGrid at all. Instead, add a layout like this:

Label: [Open [V] (kinda drop-down list)

_______________ ______________
English text: [_______________ ______________] (consider multi-line edit?)
_______________ ______________
French text: [_______________ ______________] (consider multi-line edit?)
_______________ ______________
Spanish text: [_______________ ______________] (consider multi-line edit?)

______________
| Save |
--------------
The text boxes will be data-bound to the corresponding columns of the
filtered DataView.

P.S. Hope my ASCII art won't be mangled :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Diego TERCERO" <di***********@ freesurf.fr> wrote in message
news:3f******** **************@ news.club-internet.fr...
Hi...
I'm working on a tool for editing text resources for a family of software
product my company produces.

These text resources are found in a SQL Server database, in a table called
"Resource" with the following structure :
Resource{[id],en,fr,es}
Yes.. these are the only languages supported actually.

A couple of rows in that table would look like this :
id | en | fr | es |
0000001 | Open |Ouvrir | Abrir |
0000002 | Close | Fermer | Cerrar |
etc...

I have a DataSet object, that I have filled with a SqlDataAdapter,
therefore, the first table of my Dataset is called "Resource" and has
exactly the same structure than the Table in the database.

I have a ListBox component that uses this DataSet as its DataSource. Its
DataMember property is the "Resource" table and its display member depends
on which is the primary display language that the user has chosen.

So the typical display of this listbox, if the user has chosen 'en' would be :
Open
Close
....

Then, when a user selects one of the list items, I use the selected row to
fill a DataGrid component in order to allow the user to edit all language
versions of the resource in a DataGrid.

Now here comes my problem. If I use a filtered version of this DataSet as
the DataSource of my DataGrid (for example a DataViewManager ), the grid will have exactly the same look than the table I have shown above. That doesn't
work for me, cause some resources could be very long error messages,
therefore, I would like to show each column of the table as a row in the
datagrid, something like this (assuming that I have chosen the item 0000001 Language | Value
en | Close
fr | Fermer
es | Cerrar

As for now, I have manually done this transformation by creating a table
called "ResourceIt em" in the DataSource bounded to my DataGrid which I fill by looping on the columns of the selected row. Here's a sample :

foreach(DataCol umn col in drSelectedRow.T ables["Resource"].Columns){
DataRow newGridRow = dsGridDataSet.T ables["ResourceIt em"].Rows.NewRow(); newGridRow["Language"] = col.ColumnName;
newGridRow["Value"] = drSelectedRow[col].ToString();
dsGridDataSet.A dd(newGridRow);
}

I don't like this solution 'cause it's finally not a matter of datastructure but a matter of display. I just would like to be able to show the columns of my original DataSet as rows in my DataGrid. Any idea how can I achieve that ?

Thanxs,

Diego

P.S. : I'm aware of the cool ways to manage Globalization in .Net and
resource files, but this is not my question. The purpose of my tool is to
edit resource files for legacy software programmed in VB6 or in ASP 4.0. So the edition of resources is to be done with this tool I'm working on in C#
but the edited resource files are intended to be used by other older
software.



Nov 15 '05 #2
Hi Dimitry,
I have thought about this solution.
The problem is that I wanted to use a DataGrid because the number of
available languages is not fixed : it is supposed to be known dynamically.
That means, that my DataGrid is bounded to a DataSet that has a structure
that I don't know at design time, only at runtime (I give users the
possibility to open a specific Resource table, whose structure I don't know
yet).

So a solution would be to dynamically create labels and textboxes and bound
them to the Resources dataset after having guessed which structure this
DataSet has (remember that sometimes there might be more than French,
English or Spanish... resources).

I think that doing this results in code complication, performance overhead,
and amounts the risk of generating exceptions, this is tipically the kind of
situation for which the DataGrid is pretty wel suited.

Now... my only problem is that I need to adapt its look to my issue :
display rows as columns.
I know this is possible because I've found in Google a resource that
speciffically adresses this issue, but the link is dead !

Thanxs for your help.

Diego

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> a ecrit
dans le message de news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi Diego,

I think as your users will be editing the resources row-by-row, you don't
need the DataGrid at all. Instead, add a layout like this:

Label: [Open [V] (kinda drop-down list)

_______________ ______________
English text: [_______________ ______________] (consider multi-line edit?)
_______________ ______________
French text: [_______________ ______________] (consider multi-line edit?)
_______________ ______________
Spanish text: [_______________ ______________] (consider multi-line edit?)

______________
| Save |
--------------
The text boxes will be data-bound to the corresponding columns of the
filtered DataView.

P.S. Hope my ASCII art won't be mangled :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Diego TERCERO" <di***********@ freesurf.fr> wrote in message
news:3f******** **************@ news.club-internet.fr...
Hi...
I'm working on a tool for editing text resources for a family of software product my company produces.

These text resources are found in a SQL Server database, in a table called "Resource" with the following structure :
Resource{[id],en,fr,es}
Yes.. these are the only languages supported actually.

A couple of rows in that table would look like this :
id | en | fr | es |
0000001 | Open |Ouvrir | Abrir |
0000002 | Close | Fermer | Cerrar |
etc...

I have a DataSet object, that I have filled with a SqlDataAdapter,
therefore, the first table of my Dataset is called "Resource" and has
exactly the same structure than the Table in the database.

I have a ListBox component that uses this DataSet as its DataSource. Its
DataMember property is the "Resource" table and its display member depends on which is the primary display language that the user has chosen.

So the typical display of this listbox, if the user has chosen 'en' would
be
:
Open
Close
....

Then, when a user selects one of the list items, I use the selected row
to fill a DataGrid component in order to allow the user to edit all language versions of the resource in a DataGrid.

Now here comes my problem. If I use a filtered version of this DataSet as the DataSource of my DataGrid (for example a DataViewManager ), the grid

will
have exactly the same look than the table I have shown above. That doesn't work for me, cause some resources could be very long error messages,
therefore, I would like to show each column of the table as a row in the
datagrid, something like this (assuming that I have chosen the item

0000001
Language | Value
en | Close
fr | Fermer
es | Cerrar

As for now, I have manually done this transformation by creating a table
called "ResourceIt em" in the DataSource bounded to my DataGrid which I

fill
by looping on the columns of the selected row. Here's a sample :

foreach(DataCol umn col in drSelectedRow.T ables["Resource"].Columns){
DataRow newGridRow =

dsGridDataSet.T ables["ResourceIt em"].Rows.NewRow();
newGridRow["Language"] = col.ColumnName;
newGridRow["Value"] = drSelectedRow[col].ToString();
dsGridDataSet.A dd(newGridRow);
}

I don't like this solution 'cause it's finally not a matter of

datastructure
but a matter of display. I just would like to be able to show the columns of
my original DataSet as rows in my DataGrid. Any idea how can I achieve

that
?

Thanxs,

Diego

P.S. : I'm aware of the cool ways to manage Globalization in .Net and
resource files, but this is not my question. The purpose of my tool is

to edit resource files for legacy software programmed in VB6 or in ASP 4.0.

So
the edition of resources is to be done with this tool I'm working on in C# but the edited resource files are intended to be used by other older
software.


Nov 15 '05 #3
Standard Windows Forms datagrid cannot display data with rows and columns
swapped. You should probably consider a 3rd party component, or indeed
transpose the data programatically - I think it's pretty viable solution for
your application.

I know I will be flamed for this, but, after all, the users of your
application don't care how perfect it's design is - what they care about is
how convenient and reliable it is.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Le Big Mac" <le******@somed omain.com> wrote in message
news:3f******** **************@ news.free.fr...
Hi Dimitry,
I have thought about this solution.
The problem is that I wanted to use a DataGrid because the number of
available languages is not fixed : it is supposed to be known dynamically.
That means, that my DataGrid is bounded to a DataSet that has a structure
that I don't know at design time, only at runtime (I give users the
possibility to open a specific Resource table, whose structure I don't know yet).

So a solution would be to dynamically create labels and textboxes and bound them to the Resources dataset after having guessed which structure this
DataSet has (remember that sometimes there might be more than French,
English or Spanish... resources).

I think that doing this results in code complication, performance overhead, and amounts the risk of generating exceptions, this is tipically the kind of situation for which the DataGrid is pretty wel suited.

Now... my only problem is that I need to adapt its look to my issue :
display rows as columns.
I know this is possible because I've found in Google a resource that
speciffically adresses this issue, but the link is dead !

Thanxs for your help.

Diego

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> a ecrit dans le message de news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi Diego,

I think as your users will be editing the resources row-by-row, you don't
need the DataGrid at all. Instead, add a layout like this:

Label: [Open [V] (kinda drop-down list)

_______________ ______________
English text: [_______________ ______________] (consider multi-line edit?) _______________ ______________
French text: [_______________ ______________] (consider multi-line edit?) _______________ ______________
Spanish text: [_______________ ______________] (consider multi-line edit?)
______________
| Save |
--------------
The text boxes will be data-bound to the corresponding columns of the
filtered DataView.

P.S. Hope my ASCII art won't be mangled :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Diego TERCERO" <di***********@ freesurf.fr> wrote in message
news:3f******** **************@ news.club-internet.fr...
Hi...
I'm working on a tool for editing text resources for a family of software product my company produces.

These text resources are found in a SQL Server database, in a table called "Resource" with the following structure :
Resource{[id],en,fr,es}
Yes.. these are the only languages supported actually.

A couple of rows in that table would look like this :
id | en | fr | es |
0000001 | Open |Ouvrir | Abrir |
0000002 | Close | Fermer | Cerrar |
etc...

I have a DataSet object, that I have filled with a SqlDataAdapter,
therefore, the first table of my Dataset is called "Resource" and has
exactly the same structure than the Table in the database.

I have a ListBox component that uses this DataSet as its DataSource. Its DataMember property is the "Resource" table and its display member depends on which is the primary display language that the user has chosen.

So the typical display of this listbox, if the user has chosen 'en' would
be
:
Open
Close
....

Then, when a user selects one of the list items, I use the selected row
to fill a DataGrid component in order to allow the user to edit all language versions of the resource in a DataGrid.

Now here comes my problem. If I use a filtered version of this DataSet as the DataSource of my DataGrid (for example a DataViewManager ), the
grid will
have exactly the same look than the table I have shown above. That doesn't work for me, cause some resources could be very long error messages,
therefore, I would like to show each column of the table as a row in
the datagrid, something like this (assuming that I have chosen the item 0000001
Language | Value
en | Close
fr | Fermer
es | Cerrar

As for now, I have manually done this transformation by creating a table called "ResourceIt em" in the DataSource bounded to my DataGrid which I

fill
by looping on the columns of the selected row. Here's a sample :

foreach(DataCol umn col in drSelectedRow.T ables["Resource"].Columns){
DataRow newGridRow =

dsGridDataSet.T ables["ResourceIt em"].Rows.NewRow();
newGridRow["Language"] = col.ColumnName;
newGridRow["Value"] = drSelectedRow[col].ToString();
dsGridDataSet.A dd(newGridRow);
}

I don't like this solution 'cause it's finally not a matter of

datastructure
but a matter of display. I just would like to be able to show the

columns
of
my original DataSet as rows in my DataGrid. Any idea how can I achieve

that
?

Thanxs,

Diego

P.S. : I'm aware of the cool ways to manage Globalization in .Net and
resource files, but this is not my question. The purpose of my tool is

to edit resource files for legacy software programmed in VB6 or in ASP
4.0. So
the edition of resources is to be done with this tool I'm working on

in C# but the edited resource files are intended to be used by other older
software.




Nov 15 '05 #4

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

Similar topics

1
459
by: Juan | last post by:
I built a form that displays a master-detail relation ship, now i need to add a column to the datagrid displaying the master data, this column corresponds to the text name of a column stored in the master table as an integer (the foreign key, i need to display the text name of the foreign key stored in the third table). Do i have to create another datatable in the dataset im using that includes all the information I need? Change the Sql...
2
2501
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this person is taken are shown in a DataGrid (course name, price, etc.). This is working well so far, I...
3
4878
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
2
6404
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
15440
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
5
5910
by: Genojoe | last post by:
I am using code from Help with two exceptions. (1) I increased the number of sample rows from 3 to 20, and (2) I anchored the datagrid to bottom of form so that I can change the size of the grid by changing the size of the form The code is at the following location in the January, 2004 help ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpref/html/frlrfSystemWindowsFormsDataGridClassTopic.ht You can also find it by doing a search for...
6
3755
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns corresponding to permissions to certain data classes. I want to put the permission values in combo boxes in the grid and instead of displaying the numeric values, have the combo box display a string that corresponds to the numeric value (i.e. No...
0
2074
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the end of this message, but I will start with an overview of the problem. I've made a content management solution for my work with a decently structured relational database system. The CMS stores articles. The CMS also stores related items --...
8
3079
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly on my DataGrid but I'm not sure how to get Crystal Reports 10 to use as its datasource the dataset...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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
9157
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
7725
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...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.