Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to flip an asp:DataGrid from fields on x-axis and records on y-axis to fields on y-axis and records on x-axis?

How to flip an asp:DataGrid from fields on x-axis and records on y-axis to fields on y-axis and records on x-axis?

Scheduled Pinned Locked Moved ASP.NET
tutorialcsshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cyrilix
    wrote on last edited by
    #1

    My title may not be very clear, but what it means is that normally, when we have a data set, the columns (along x-axis) refer to the properties of a specific record in the data set, whereas all the records of this data set are listed vertically (y-axis). The asp:DataGrid also works this way, in that you can have a data set with a variety of columns (BoundColumn, TemplateColumn, ButtonColumn, etc.) which all denote properties of your data. An advantage of this is that for each record, you can specify for example, that a certain column is a TemplateColumn with a DropDownList bound to another data set, allowing you to pick and choose from this data. Given this background, the problem I'm having is that I want the records to be like new columns, and the fields to be a fixed set of rows (essentially inverting the x and y-axis of the standard data grid). If I use a pivot table (just a DataTable with a pivot function that allows you to switch the x/y-axes) as a data source, I can get the data displayed by the data grid just fine. What I can't do, however, is make it so that the data grid has "TemplateRow" (this construct does not exist) and bind certain rows to data via a DropDownList, assuming I want to make this data editable. Does anyone know of a quick way to do this or do I essentially have to take apart the standard asp:DataGrid / spend a lot of time extending its functionality so that I can do the following:

    asp:DataGrid
    asp:TemplateRow
    asp:ItemStyle
    <asp:DropDownList DataSource="someDataSource"></asp:DropDownList>
    </asp:ItemStyle>
    </asp:TemplateRow>
    </asp:DataGrid>

    C 1 Reply Last reply
    0
    • C Cyrilix

      My title may not be very clear, but what it means is that normally, when we have a data set, the columns (along x-axis) refer to the properties of a specific record in the data set, whereas all the records of this data set are listed vertically (y-axis). The asp:DataGrid also works this way, in that you can have a data set with a variety of columns (BoundColumn, TemplateColumn, ButtonColumn, etc.) which all denote properties of your data. An advantage of this is that for each record, you can specify for example, that a certain column is a TemplateColumn with a DropDownList bound to another data set, allowing you to pick and choose from this data. Given this background, the problem I'm having is that I want the records to be like new columns, and the fields to be a fixed set of rows (essentially inverting the x and y-axis of the standard data grid). If I use a pivot table (just a DataTable with a pivot function that allows you to switch the x/y-axes) as a data source, I can get the data displayed by the data grid just fine. What I can't do, however, is make it so that the data grid has "TemplateRow" (this construct does not exist) and bind certain rows to data via a DropDownList, assuming I want to make this data editable. Does anyone know of a quick way to do this or do I essentially have to take apart the standard asp:DataGrid / spend a lot of time extending its functionality so that I can do the following:

      asp:DataGrid
      asp:TemplateRow
      asp:ItemStyle
      <asp:DropDownList DataSource="someDataSource"></asp:DropDownList>
      </asp:ItemStyle>
      </asp:TemplateRow>
      </asp:DataGrid>

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You need to use a repeater to have that level of control over the output. Even then, you want to use a pivot table for your data

      Christian Graus Driven to the arms of OSX by Vista.

      C 1 Reply Last reply
      0
      • C Christian Graus

        You need to use a repeater to have that level of control over the output. Even then, you want to use a pivot table for your data

        Christian Graus Driven to the arms of OSX by Vista.

        C Offline
        C Offline
        Cyrilix
        wrote on last edited by
        #3

        Thanks, I will have a look at this control.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups