How can I make a header column span?

  • Thread starter Thread starter Stan
  • Start date Start date
S

Stan

I would like my header column span multiple columns, for example:

Date
Ready Open Close
---------------------------
08/06 10 am 5pm

How can I do that?

Thanks,

-Stan
 
Hello,

How about nesting a datagrid in a template column of another datagrid?

HTH,
 
Hmm...

Not sure I understood that...

The problem is that neither <asp:boundcolumn> no <asp:templatecolumn>
provide a way
of splitting a header colum:

Store ! Time
---- ----------------------------
! Open ! Close
 
Hello,

Please have a look at the following code. It will clarify my post. I know
it is not the best anwser. but at least it works.

<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Store">
<ItemTemplate>
<asp:DataGrid id=DataGrid2 runat="server" DataSource="<%#
MyDataSet1 %>" DataMember="YourTableName" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="Store"
SortExpression="Store"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Time">
<ItemTemplate>
<asp:DataGrid id=DataGrid3 runat="server" DataSource="<%#
MyDataSet1 %>" DataMember="YourTableName" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="Open"
SortExpression="Open" HeaderText="CompanyName"></asp:BoundColumn>
<asp:BoundColumn DataField="Close"
SortExpression="Close" HeaderText="ContactName"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>


------------------------------------------------------

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(MyDataSet1)
Dim values As ArrayList = New ArrayList()
values.Add(0)
DataGrid1.DataSource = values
DataGrid1.DataBind()
End Sub

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
Dim dg As DataGrid
dg = e.Item.FindControl("DataGrid2")
If Not dg Is Nothing Then
dg.DataBind()
End If
dg = e.Item.FindControl("DataGrid3")
If Not dg Is Nothing Then
dg.DataBind()
End If
End Sub
 
Back
Top