I have a datatable with many columns, like so;
Name | Age | Foo | Bar | Etc..
Joe | 30 | foo | bar | Etc..
I need to now get this datatable into just two columns consisting of just the headers followed by their values, like so;
Header | Value
Name | Joe
Age | 30
Foo | foo
Etc... | etc..
This is so that a DataBinder can access it easily when the data is bound.
How can this be done, and do I need to do this at all?
EDIT: Including example code
asp.net
<div class="itemDetail col-s">
<div class="itemDetailLabel">
<%# DataBinder.Eval(Container.DataItem, "Caption")%>
</div>
<div class="itemDetailValue">
<%# If(DataBinder.Eval(Container.DataItem, "UIValue") Is Nothing OrElse String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem, "UIValue").ToString()), " ", DataBinder.Eval(Container.DataItem, "UIValue")) %>
</div>
</div>
vb.net
Dim oldDataTable As DataTable = DataSource ''Which is a datatable of a single row
Dim newDataTable As New DataTable
newDataTable.Columns.Add("Caption")
newDataTable.Columns.Add("UIValue")
''Change the single row into multiple rows
fooControl.DataSource = newDataTable
fooControl.DataBind()
EDIT2: So for those that are still learning like me, this is called transposing. Thanks for @gofal3 for pointing it out