Hi All
Hope you can help.
I have 2 datagrids on a form. I am trying to add headers to each grid so that both grids look like this:
grid 1
------------------------------------------------------------------
| | Monday | Tuesday | Wednesday |
------------------------------------------------------------------
|Ward | Occ | % | Occ | % | Occ | % |
------------------------------------------------------------------
| 1 | 6 | 50 | 4 | 95 | 12 | 100 |
------------------------------------------------------------------
grid 2
------------------------------------------------------------------
| | Monday | Tuesday | Wednesday |
------------------------------------------------------------------
|Ward | thr | % | thr | % | thr | % |
------------------------------------------------------------------
| 1 | 6 | 50 | 4 | 95 | 12 | 100 |
------------------------------------------------------------------
What my code actually does is doubles up the days on the first grid e.g.
grid 1
------------------------------------------------------------------
| | Monday | Tuesday | Wednesday |
------------------------------------------------------------------
| | Monday | Tuesday | Wednesday |
------------------------------------------------------------------
|Ward | Occ | % | Occ | % | Occ | % |
------------------------------------------------------------------
| 1 | 6 | 50 | 4 | 95 | 12 | 100 |
------------------------------------------------------------------
grid2
------------------------------------------------------------------
|Ward | Occ | % | Occ | % | Occ | % |
------------------------------------------------------------------
| 1 | 6 | 50 | 4 | 95 | 12 | 100 |
------------------------------------------------------------------
here is the code for the design:
Code:
<asp:DataGridBorderStyle="Solid"BorderWidth="1"BorderColor="#0066ff"ID="grdOccupRpt"AutoGenerateColumns="false"runat="server"Width="100%">
<AlternatingItemStyleBackColor="#ccffff"Font-Names="tahoma"Font-Size="Small"Width="300px"/><ItemStyleBackColor="#99ccff"Font-Names="tahoma"Font-Size="Small"Width="150px"/>
<HeaderStyleBackColor="#3399ff"Font-Names="tahoma"Font-Size="Small"ForeColor="black"Font-Bold="true"/>
<Columns>
<asp:boundcolumnDataField="ward"HeaderText="Ward">
</asp:boundcolumn>
<asp:boundcolumnDataField="monavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="monocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="monoccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="tueavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="tueocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="tueoccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="wedavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="wedocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="wedoccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="thuavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="thuocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="thuoccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="friavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="friocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="frioccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="satavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="satocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="satoccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="sunavail"HeaderText="Avail">
</asp:boundcolumn>
<asp:boundcolumnDataField="sunocc"HeaderText="Occ">
</asp:boundcolumn>
<asp:boundcolumnDataField="sunoccpt"HeaderText="Perc"DataFormatString="{0:F1}%">
</asp:boundcolumn>
</Columns>
</asp:DataGrid>
<br/>
<br/>
<div>
<h3>
Ward Throughput Report for <% Response.Write(fn_findStartEndDate("sta", Application("strNowdate")))%> and <% Response.Write(fn_findStartEndDate("end", Application("strNowdate")))%>
</h3>
</div>
<br/>
<br/>
<asp:DataGridBorderStyle="Solid"BorderWidth="1"BorderColor="#0066ff"ID="grdThruPutRpt"AutoGenerateColumns="false"runat="server"Width="100%">
<AlternatingItemStyleBackColor="#ccffff"Font-Names="tahoma"Font-Size="Small"Width="300px"/><ItemStyleBackColor="#99ccff"Font-Names="tahoma"Font-Size="Small"Width="150px"/>
<HeaderStyleBackColor="#3399ff"Font-Names="tahoma"Font-Size="Small"ForeColor="black"Font-Bold="true"/>
<Columns>
<asp:boundcolumnDataField="ward"HeaderText="Ward">
</asp:boundcolumn>
<asp:boundcolumnDataField="monavail"HeaderText="MonAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="monthru"HeaderText="Monthru">
</asp:boundcolumn>
<asp:boundcolumnDataField="monpt"HeaderText="MonPT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="tueavail"HeaderText="TueAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="tuethru"HeaderText="Tuethru">
</asp:boundcolumn>
<asp:boundcolumnDataField="tuePT"HeaderText="TuePT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="wedavail"HeaderText="WedAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="wedthru"HeaderText="Wedthru">
</asp:boundcolumn>
<asp:boundcolumnDataField="wedpt"HeaderText="WedPT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="thuavail"HeaderText="ThuAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="thuthru"HeaderText="Thuthru">
</asp:boundcolumn>
<asp:boundcolumnDataField="thupt"HeaderText="ThuPT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="friavail"HeaderText="FriAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="frithru"HeaderText="Frithru">
</asp:boundcolumn>
<asp:boundcolumnDataField="fript"HeaderText="FriPT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="satavail"HeaderText="SatAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="satthru"HeaderText="Satthru">
</asp:boundcolumn>
<asp:boundcolumnDataField="satpt"HeaderText="SatPT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
<asp:boundcolumnDataField="sunavail"HeaderText="SunAvail">
</asp:boundcolumn>
<asp:boundcolumnDataField="sunthru"HeaderText="Sunthru">
</asp:boundcolumn>
<asp:boundcolumnDataField="sunpt"HeaderText="SunPT"DataFormatString="{0:F1}%">
</asp:boundcolumn>
</Columns>
</asp:DataGrid>
and here is the code behind for the itemcreate handlers
Code:
ProtectedSub grdOccupRpt_itemcreated(ByVal sender AsObject, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Header Then
Dim dgItem As DataGridItem = New DataGridItem(0, 0, ListItemType.Header)
Dim dgCell As TableCell = New TableCell()
dgCell.ColumnSpan = 1
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = ""
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "Mon"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "Tue"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "Wed"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "Thu"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "Fri"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "sat"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
dgCell = New TableCell()
dgCell.ColumnSpan = 3
dgCell.HorizontalAlign = HorizontalAlign.Center
dgItem.Cells.Add(dgCell)
dgCell.Text = "sun"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem)
EndIf
EndSub
ProtectedSub grdThruPutRpt_itemcreated(ByVal sender AsObject, ByVal e As DataGridItemEventArgs) Handles grdThruPutRpt.ItemCreated
If e.Item.ItemType = ListItemType.Header Then
Dim dgItem1 As DataGridItem = New DataGridItem(0, 0, ListItemType.Header)
Dim dgCell1 As TableCell = New TableCell()
dgCell1.ColumnSpan = 1
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = ""
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "Mon"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "Tue"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "Wed"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "Thu"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "Fri"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "sat"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
dgCell1 = New TableCell()
dgCell1.ColumnSpan = 3
dgCell1.HorizontalAlign = HorizontalAlign.Center
dgItem1.Cells.Add(dgCell1)
dgCell1.Text = "sun"
grdOccupRpt.Controls(0).Controls.AddAt(0, dgItem1)
EndIf
EndSub
if anyone can give me any pointers i would appreciate it.
Rob