I would use a custom server control for such a display. I threw this
together to
give you an idea, hope it helps.
William
PS
This code goes in the App_Code folder. I named the file Ralph.vb
You then need to register the namespace in your web.config file
Example:
<controls>
<add tagPrefix="RalphControls" namespace="RalphControls" />
</controls>
The control accepts 2 parameters, the DataSource (as a DataTable) and the
number of columns
you want displayed in a table row.
Again, it's just thrown together and can use improvement, but it may open
you up to new types of solutions.
///////////////////////////////////////////////////////////////
Imports Microsoft.VisualBasic
Namespace RalphControls
Public Class QuadViewDataViewer
Inherits CompositeControl
Protected Overrides Sub CreateChildControls()
MyBase.Controls.Clear()
If DataSource IsNot Nothing AndAlso DataSource.Tables(0) IsNot
Nothing Then
Dim Table_Main As New HtmlGenericControl("table")
With Table_Main
'Add any Table Attributes you require
With .Attributes
.Add("cellspacing", "0px")
End With
'Add any Table Styles you require
With .Style
.Add("border", "1px solid black")
End With
'Loop through each row in your DataSource
Dim RowCounter As Integer = 0
For Each DR As System.Data.DataRow In
DataSource.Tables(0).Rows
'Determine when to start a new row.
If RowCounter = 0 OrElse (RowCounter - 1) Mod
NumberOfColumns = 0 Then
.Controls.Add(New LiteralControl("<TR>"))
End If
Dim Table_Main_TableCell As New
HtmlGenericControl("td")
With Table_Main_TableCell
Dim ColumnOne As String = CStr(DR("Column1"))
Dim ColumnTwo As String = CStr(DR("Column2"))
Dim ColumnThree As String = CStr(DR("Column3"))
Dim ColumnFour As String = CStr(DR("Column4"))
'Create your "Quad View" Table.
Dim Table_QuadView As New
HtmlGenericControl("table")
With Table_QuadView
Dim Table_QuadView_FirstRow As New
HtmlGenericControl("tr")
With Table_QuadView_FirstRow
Dim Table_QuadView_FirstRow_ColumnOne As
New HtmlGenericControl("td")
With Table_QuadView_FirstRow_ColumnOne
'Create your output for the top-left
column.
'In this sample, I am just
outputting the text found in the
'datacolumn, but you can create any
control you desire.
.Controls.Add(New
LiteralControl(ColumnOne))
End With
.Controls.Add(Table_QuadView_FirstRow_ColumnOne)
Dim Table_QuadView_FirstRow_ColumnTwo As
New HtmlGenericControl("td")
With Table_QuadView_FirstRow_ColumnTwo
'Create your output for the
top-right column.
.Controls.Add(New
LiteralControl(ColumnTwo))
End With
.Controls.Add(Table_QuadView_FirstRow_ColumnTwo)
End With
.Controls.Add(Table_QuadView_FirstRow)
Dim Table_QuadView_SecondRow As New
HtmlGenericControl("tr")
With Table_QuadView_SecondRow
Dim Table_QuadView_SecondRow_ColumnOne
As New HtmlGenericControl("td")
With Table_QuadView_SecondRow_ColumnOne
'Create your output for the
bottom-left column.
.Controls.Add(New
LiteralControl(ColumnThree))
End With
.Controls.Add(Table_QuadView_SecondRow_ColumnOne)
Dim Table_QuadView_SecondRow_ColumnTwo
As New HtmlGenericControl("td")
With Table_QuadView_SecondRow_ColumnTwo
'Create your output for the
bottom-right column.
.Controls.Add(New
LiteralControl(ColumnFour))
End With
.Controls.Add(Table_QuadView_SecondRow_ColumnTwo)
End With
.Controls.Add(Table_QuadView_SecondRow)
End With
.Controls.Add(Table_QuadView)
End With
.Controls.Add(Table_Main_TableCell)
'Determine when to end a row.
If RowCounter Mod NumberOfColumns = 0 Then
.Controls.Add(New LiteralControl("</TR>"))
End If
RowCounter += 1
Next DR
End With
'Add teh Table to your control
MyBase.Controls.Add(Table_Main)
End If
End Sub
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
MyBase.RenderContents(writer)
End Sub
Protected m_DataSource As System.Data.DataSet = Nothing
Public Property DataSource() As System.Data.DataSet
Get
Return m_DataSource
End Get
Set(ByVal value As System.Data.DataSet)
m_DataSource = value
End Set
End Property
Protected m_NumberOfColumns As Integer = 2
Public Property NumberOfColumns() As Integer
Get
Return m_NumberOfColumns
End Get
Set(ByVal value As Integer)
m_NumberOfColumns = value
End Set
End Property
End Class
End Namespace
////////////////////////////////////////////////////////////////