Results 1 to 3 of 3
  1. #1
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    rotating DataGrid (VB.Net)

    This isn't necessarily a .Net question even though I'm using .Net for this app. It's for any development thingy that lets you use a datagrid type of control. <img src=/S/blackteeth.gif border=0 alt=blackteeth width=20 height=20>

    I'm trying to use a datagrid but I want to display the data such that the rows are the cols and the cols are the rows (which is the opposite of how it's stored in the database). I'm sure there's a way to transpose these for display purposes only but the datagrid control is quite complex so I haven't figured it out yet.

    I am storing quarterly data (for 10 years so 40 quarters) for four data types. The database table has four fields (cols) with each storing 40 data items (with field names, like Y1Q1, Y1Q2, Y1Q3, Y1Q4, Y2Q1, etc.)

    This is fine for storing, but for the user to edit the data in the datagrid form in my application. it's much easier to do it like Excel in that the quarterly data is represented as rows not colums.

    For display only I want:
    <pre>Field Name | Y1Q1 | Y1Q2 | Y1Q2 | Y1Q3 | Y1Q4 | Y2Q1 |
    ----------------------------------------------------------------
    DataNameA 10 15 20 25 25 25
    DataNameB 30 30 30 30 40 40</pre>

    So, what attribute of a datagrid control lets me rotate the stored data? <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Thnx, Deb

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: rotating DataGrid (VB.Net)

    If you are using ADO.NET, this article describes how to create a new crosstab table in your dataset from the existing DataTable objects. Maybe this is the way to get the view you want? On the other hand, it probably doesn't give you the editing capability you're looking for....

  3. #3
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: rotating DataGrid (VB.Net)

    Thanks for the link. I'll read it in detail later. <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30> This data source is actually an XML file but for the purposes of the datagrid it doesn't matter (could be text file, whatever). I originally had four datagrids one for each variable but then I had to figure out how to keep them in sync so if the user was entering data for item Year2Quarter3, I had to scroll the other three grids to position themsevles at that same location since the the data for the other datagrids go together. What a pain !!

    I'm still searching for the ultimate source on all the ins/outs of the datagrid. Most books seem to focus on the SQL part of it not the manipulating the grid properties to look/behave a certain way.

    Actually.... my IDEAL solution <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15> is to embed Excel inside a window of my form. I don't want it launched as a separate window but a real spreadsheet inside a window/area on my application's main form. I haven't read much about manipulating Excel in .Net but am still hunting. I know it can be done. My users are familiar with Excel and if I can just display a spreadsheet they'll know what to do.

    Thnx, Deb <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •