Unable to provide more details on the title, please refer to the links below. Using DataGrid (not GridView) in ASP.net with VB code.
Current display in my datagrid: view picture1 here, I want it to be like this view picture2 here
The goal is to split my datagrid into multiple parts if there are multiple columns. This splitting is necessary for a better print preview in Google Chrome. The current output has all multicolumn data packed in one grid, making it difficult to read and comprehend, like shown here in picture3
If you have any suggestions on how to improve printing the datagrid in browsers, I would appreciate it. TIA.
<asp:DataGrid Visible ="true" OnItemDataBound="Item_Bound" ID="dgSheet"
runat="server" BackColor="White" BorderColor="black" BorderStyle="None"
BorderWidth="1px" CellSpacing="0" CellPadding="0" Width="100%" PageSize="5"
CssClass="Narrow" ForeColor="Black">
<EditItemStyle BackColor="#999999" />
<FooterStyle BackColor="#2980b9" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2980b9" ForeColor="White" HorizontalAlign="Center" />
<ItemStyle Font-Size="12px" Width="200" ForeColor="#333333" />
<HeaderStyle Font-Bold="true" Font-Size="12px" Width="200" ForeColor="black" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:DataGrid>
Part of my code behind for displaying data in the datagrid:
Dim o_Row As DataRow
Dim o_AdmDates As New Collection()
Dim s_LastAdmDate As String = ""
Dim s_AdmDate As String = ""
Dim o_DerivedTable As New DataTable()
With o_DerivedTable
.Columns.Add("TransDate")
.Columns.Add("Medication")
.Columns.Add("Dosage")
.Columns.Add("TransNum")
.Columns.Add("AdministeredDate")
.Columns.Add("newAdmed")
End With
'Sorting by administered dates
Dim o_FoundRows As DataRow() = o_Dataset.Tables(0).Select("", "AdministeredDate Desc")
'Extracting distinct administered dates
For Each o_Row In o_FoundRows
s_AdmDate = Format(CDate(o_Row.Item("AdministeredDate")), KC_Date_Format2)
If s_LastAdmDate <> s_AdmDate Then
s_LastAdmDate = s_AdmDate
o_AdmDates.Add(s_LastAdmDate)
End If
Next
'Adding administred date to derived table
Dim o_Item As String
For Each o_Item In o_AdmDates
o_DerivedTable.Columns.Add(o_Item)
Next
'Looping through the administred date
Dim o_NewRow As DataRow
Dim o_NextRow As DataRow
Dim i_Ctr As Integer
Dim x_isNewRow As Boolean = True
Dim i_MaxRec As Integer
i_MaxRec = o_Dataset.Tables(0).Rows.Count - 1
For i_Ctr = 0 To i_MaxRec
o_Row = o_Dataset.Tables(0).Rows(i_Ctr)
If i_Ctr <> i_MaxRec Then
o_NextRow = o_Dataset.Tables(0).Rows(i_Ctr + 1)
End If
If x_isNewRow Then
o_NewRow = o_DerivedTable.NewRow()
End If
//Additional code lines continue...