473,440 Members | 1,655 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,440 software developers and data experts.

[vb. net ] Problem with datagrid ???

Hi,
I have a problem with dataGrid. I have a query to database and it returns me
to datagrid, something like this:

--------------------
| Name | Class |
|BBBBB| 2 |
|aaa | 5 |
--------------------

Can i like make it to format such as
______________________
|Name | BBBBB| aaaaaaa |
|Class | 2 | 5 |
-------------------------------

Please adivce....

Mayby somebody have some code in VB. NET or some example apllication with
code.Please send me ... if you want ofcourse.
My e-mial: lj*****@o2.pl

Thanks Luk
--
Pozdrawiam Łukasz
Nov 21 '05 #1
2 1096
I don't think there is a way to have the datagrid reverse rows and collumns,
but what you can do is loop through your dataset and create a new dataset
with the rows and columns reversed.

This function will tkae a datatable and turn the rows into columns and the
columns into rows.

Where dattbl1 is your original datatable...

dim dattbl2 as datatable
dattbl2 = ReverseTable(dattbl1)
DataGrid2.DataSource = dattbl2

Private Function ReverseTable(ByVal dattbl1 As DataTable) As DataTable
Dim i, x As Integer
Dim strDummy As String = ""
Dim datTableOut As New DataTable
Dim dr As DataRow
datTableOut.Columns.Add("ColumnName", strDummy.GetType)
For i = 0 To dattbl1.Rows.Count - 1
datTableOut.Columns.Add("Column" & i, strDummy.GetType)
Next
For i = 0 To dattbl1.Columns.Count - 1
dr = datTableOut.NewRow()
dr("ColumnName") = dattbl1.Columns(i).ColumnName
For x = 0 To dattbl1.Rows.Count - 1
dr("Column" & x) = dattbl1.Rows(x).Item(i)
Next
datTableOut.Rows.Add(dr)
Next
Return datTableOut
End Function

"Szaki" <lj**@gazeta.pl> wrote in message
news:dk**********@inews.gazeta.pl...
Hi,
I have a problem with dataGrid. I have a query to database and it returns me to datagrid, something like this:

--------------------
| Name | Class |
|BBBBB| 2 |
|aaa | 5 |
--------------------

Can i like make it to format such as
______________________
|Name | BBBBB| aaaaaaa |
|Class | 2 | 5 |
-------------------------------

Please adivce....

Mayby somebody have some code in VB. NET or some example apllication with
code.Please send me ... if you want ofcourse.
My e-mial: lj*****@o2.pl

Thanks Luk
--
Pozdrawiam Łukasz

Nov 21 '05 #2
Looks like you're after a crosstab query where columns become rows. What's
your sql?

"Szaki" <lj**@gazeta.pl> wrote in message
news:dk**********@inews.gazeta.pl...
Hi,
I have a problem with dataGrid. I have a query to database and it returns me to datagrid, something like this:

--------------------
| Name | Class |
|BBBBB| 2 |
|aaa | 5 |
--------------------

Can i like make it to format such as
______________________
|Name | BBBBB| aaaaaaa |
|Class | 2 | 5 |
-------------------------------

Please adivce....

Mayby somebody have some code in VB. NET or some example apllication with
code.Please send me ... if you want ofcourse.
My e-mial: lj*****@o2.pl

Thanks Luk
--
Pozdrawiam Łukasz

Nov 21 '05 #3

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

Similar topics

2
by: Ashish Patel | last post by:
Hi..friends I am .NET developer and using ASP.NET I have one problem with datagrid. I put one datagrid on the webform. When the user clicks on the Edit link then it shows some textbox in the...
0
by: Brett Hargreaves | last post by:
I'm having major problems with Datagrid and the update command. Basically when I enter into edit mode in my data grid then set a new value, the update command is not picking up the new value. ...
1
by: Brett Hargreaves | last post by:
I'm having a major problems with Datagrid and the update command. Basically when I enter into edit mode in my data grid then set a new value, the update command is not picking up the new value....
1
by: Alagu | last post by:
Hi all, I am looking for some pointers as to how to do paging with datagrid.. Well, there are so many samples out there.. What I am looking for is to be able to have a dynamic query where the...
0
by: ad | last post by:
I want to let user edit data in datagrid. But is not convenient to develop with datagrid. Are there any third party tools can do better with it?
0
by: suresh | last post by:
How to validate input with datagrid control? i tried the following code from msdn...i have problem in adding handler to the columnchanging event..its not working for me? any bug in this code? is...
1
by: AstronusX | last post by:
How to check if a Key is press down with datagrid control? I try to use OnKeyDown Event but it doesnot work? Help?
1
by: sathyan8294 | last post by:
how to work with datagrid using 1)delete command( permanently to remove all selected rows or selected single rows) in sql database through datagrid during run time in vb.net windows application...
0
by: Mani kansal | last post by:
hi, i have a problem with datagrid.Im using 2 dropdown lists in the datagrid.. and i want to fill one dropdown list on the selection of the item of the other one... like one grid is getting...
0
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,...
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
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
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...
0
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...

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.