Solved

Asp.Net: how-to make datagrid headers appearing vertically

Posted on 2004-08-18
9
384 Views
Last Modified: 2012-06-27
Hello experts,
in my Asp.Net (vb.net) web application is a datagrid as follows:
---
<asp:datagrid id="dgX" OnItemCommand="showX" > 
  <Columns>
    <asp:BoundColumn DataField="UserID" HeaderText="UserID" />
  </Columns>
</asp:datagrid>
---
Now I want to ensure that the HeaderText for the sample field appears in the datagrid vertically.
The text in the datagrid's body shall remain appearing horizontally.
How can I do this?

If anyone knows a solution please supply appropriate [snippet] information.

   Thank you very much!

     HStrix
 
0
Comment
Question by:HStrix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 250 total points
ID: 11838584
Hi,

if you mean that the header text should not show as
UserId
but as
U
s
e
r
I
D

you should do that through the ItemDataBound event like

        If e.Item.ItemType = ListItemType.Header Then
            Dim index As Integer
            Dim headerText As String
            For index = 0 To e.Item.Cells(0).Text.Length - 1
                headerText = headerText & e.Item.Cells(0).Text.Substring(index, 1) & "<br>"
            Next
            e.Item.Cells(0).Text = headerText
        End If

Regards,
B..M
0
 

Author Comment

by:HStrix
ID: 11838653
Thank you mmarinov,
that works, but only for the first element of the datagrid.

<asp:datagrid id="dgX" OnItemCommand="showX" > 
  <Columns>
    <asp:BoundColumn DataField="UserID" HeaderText="UserID" />            <== that works
    <asp:BoundColumn DataField="UserName" HeaderText="UserName" />  <== that doesn't work
  </Columns>
</asp:datagrid>


0
 
LVL 3

Expert Comment

by:alexpreston
ID: 11838687
       If e.Item.ItemType = ListItemType.Header Then
            Dim index As Integer
            Dim headerText As String
For cellCount = 0 To e.Item.Cells.Count
            For index = 0 To e.Item.Cells(cellCount).Text.Length - 1
                headerText = headerText & e.Item.Cells(cellCount).Text.Substring(index, 1) & "<br>"
            Next
Next
            e.Item.Cells(0).Text = headerText
        End If
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Assisted Solution

by:alexpreston
alexpreston earned 250 total points
ID: 11838698
oops, messed that up

 If e.Item.ItemType = ListItemType.Header Then
            Dim index As Integer
            Dim headerText As String
For cellCount = 0 To e.Item.Cells.Count
            For index = 0 To e.Item.Cells(cellCount).Text.Length - 1
                headerText = headerText & e.Item.Cells(cellCount).Text.Substring(index, 1) & "<br>"
            Next
            e.Item.Cells(cellCount).Text = headerText
Next
        End If
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 11838708
yes because i show you the way
you have to do that for every header text

Regards,
B..M
0
 
LVL 3

Expert Comment

by:alexpreston
ID: 11838757
Yes. Once you know to use the  ItemDataBound event it's pretty easy. Although I think I messed it up again, should have used  "e.Item.Cells.Count - 1".

(it's too early in the morning!)
0
 

Author Comment

by:HStrix
ID: 11838762
Thank you very much mmarinow and alexpreston.
I modified the code to
---
        If e.Item.ItemType = ListItemType.Header Then
            Dim cellCount As Integer
            Dim index As Integer
            Dim headerText As String
            For cellCount = 0 To e.Item.Cells.Count - 1
                headerText = ""
                For index = 0 To e.Item.Cells(cellCount).Text.Length - 1
                    headerText = headerText & e.Item.Cells(cellCount).Text.Substring(index, 1) & "<br>"
                Next
                e.Item.Cells(cellCount).Text = headerText
            Next
        End If
---
0
 
LVL 3

Expert Comment

by:alexpreston
ID: 11838773
Oh dear, forgot to reset headerText too. I'm bad. :-)
0
 

Author Comment

by:HStrix
ID: 11838785
OK, thank you both again for your help.

  HStrix
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question