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?
-
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> -
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>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.
-
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.