By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Headers in Datagrid spanning multiple columns.

P: n/a
I am using a datagrid to display some data. I need to
create 2 header rows for this grid with columns of
varying spans. In html it would be the following.

<Table>
<tr>
<td colspan=8>Official Impact Summary</td>
</tr>
<tr>
<td colspan=2></td>
<td colspan=3>Program Totals</td>
<td colspan=3>Official Totals</td>
</tr>
<tr><td></td>...

Is this kind of thing possible with a datagrid and if so
how do I do it.

Thanks,

Billy Jacobs
Jul 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a

Hi Billy,

If you want to add one head row to the datagrid, you can use the
HeaderStyle.
If you want to add more rows, you can simply create a parent table which
contains
your 2 tablerows, then place the datagrid control into the bottom table
item.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Billy Jacobs" <bi********@csa.com>
| Sender: "Billy Jacobs" <bi********@csa.com>
| Subject: Headers in Datagrid spanning multiple columns.
| Date: Sun, 14 Sep 2003 00:28:13 -0700
| Lines: 21
| Message-ID: <04****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN6kcGQTlsc6vV6SDiL96c0/deuoQ==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:108413
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| I am using a datagrid to display some data. I need to
| create 2 header rows for this grid with columns of
| varying spans. In html it would be the following.
|
| <Table>
| <tr>
| <td colspan=8>Official Impact Summary</td>
| </tr>
| <tr>
| <td colspan=2></td>
| <td colspan=3>Program Totals</td>
| <td colspan=3>Official Totals</td>
| </tr>
| <tr><td></td>...
|
| Is this kind of thing possible with a datagrid and if so
| how do I do it.
|
| Thanks,
|
| Billy Jacobs
|

Jul 21 '05 #2

P: n/a
Yes but I need the header rows in the parent table to
exactly span a certain number of rows in the child table.

Is this possible and if so could you send me a small
example?

Thanks,

Billy Jacobs
-----Original Message-----

Hi Billy,

If you want to add one head row to the datagrid, you can use theHeaderStyle.
If you want to add more rows, you can simply create a parent table whichcontains
your 2 tablerows, then place the datagrid control into the bottom tableitem.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Billy Jacobs" <bi********@csa.com>
| Sender: "Billy Jacobs" <bi********@csa.com>
| Subject: Headers in Datagrid spanning multiple columns.
| Date: Sun, 14 Sep 2003 00:28:13 -0700
| Lines: 21
| Message-ID: <04****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300| Thread-Index: AcN6kcGQTlsc6vV6SDiL96c0/deuoQ==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:108413| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| I am using a datagrid to display some data. I need to
| create 2 header rows for this grid with columns of
| varying spans. In html it would be the following.
|
| <Table>
| <tr>
| <td colspan=8>Official Impact Summary</td>
| </tr>
| <tr>
| <td colspan=2></td>
| <td colspan=3>Program Totals</td>
| <td colspan=3>Official Totals</td>
| </tr>
| <tr><td></td>...
|
| Is this kind of thing possible with a datagrid and if so| how do I do it.
|
| Thanks,
|
| Billy Jacobs
|

.

Jul 21 '05 #3

P: n/a

Hi Billy,

I think I do not quite understand your meanning.
What do you mean that "span a certain number of rows in the child table"?
I can not form an image of what you want in my mind.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Billy Jacobs" <bi********@csa.com>
| Sender: "Billy Jacobs" <bi********@csa.com>
| References: <04****************************@phx.gbl>
<x$**************@cpmsftngxa07.phx.gbl>
| Subject: RE: Headers in Datagrid spanning multiple columns.
| Date: Thu, 18 Sep 2003 20:13:32 -0700
| Lines: 81
| Message-ID: <0b****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN+XAFsRhWAifrPTYmLs5IHxzy8SA==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:109133
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Yes but I need the header rows in the parent table to
| exactly span a certain number of rows in the child table.
|
| Is this possible and if so could you send me a small
| example?
|
| Thanks,
|
| Billy Jacobs
| >-----Original Message-----
| >
| >Hi Billy,
| >
| >If you want to add one head row to the datagrid, you can
| use the
| >HeaderStyle.
| >If you want to add more rows, you can simply create a
| parent table which
| >contains
| >your 2 tablerows, then place the datagrid control into
| the bottom table
| >item.
| >
| >Hope this helps.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Billy Jacobs" <bi********@csa.com>
| >| Sender: "Billy Jacobs" <bi********@csa.com>
| >| Subject: Headers in Datagrid spanning multiple columns.
| >| Date: Sun, 14 Sep 2003 00:28:13 -0700
| >| Lines: 21
| >| Message-ID: <04****************************@phx.gbl>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcN6kcGQTlsc6vV6SDiL96c0/deuoQ==
| >| Newsgroups: microsoft.public.dotnet.general
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.general:108413
| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| X-Tomcat-NG: microsoft.public.dotnet.general
| >|
| >| I am using a datagrid to display some data. I need to
| >| create 2 header rows for this grid with columns of
| >| varying spans. In html it would be the following.
| >|
| >| <Table>
| >| <tr>
| >| <td colspan=8>Official Impact Summary</td>
| >| </tr>
| >| <tr>
| >| <td colspan=2></td>
| >| <td colspan=3>Program Totals</td>
| >| <td colspan=3>Official Totals</td>
| >| </tr>
| >| <tr><td></td>...
| >|
| >| Is this kind of thing possible with a datagrid and if
| so
| >| how do I do it.
| >|
| >| Thanks,
| >|
| >| Billy Jacobs
| >|
| >
| >.
| >
|

Jul 21 '05 #4

P: n/a
Sorry I meant that I need the headers to span a certain
number of columns as described here.

I want to accomplish the following except with a datagrid.

<Table>
<tr>
<td colspan=8>Official Impact Summary</td>
</tr>
<tr>
<td colspan=2></td>
<td colspan=3>Program Totals</td>
<td colspan=3>Official Totals</td>
</tr>
<tr> 'Here would be my bound rows.
<td>Col1Info</td><td>Col2Info</td><td>Col3Info</td>
<td>Col4Info</td><td>Col5Info</td><td>Col6Info</td>
<td>Col7Info</td><td>Col8Info</td>
</tr>
<tr>...</table>
Thanks,

Billy Jacobs

Jul 21 '05 #5

P: n/a

Hi Billy,

I think what I originally suggested is a suitable solution.
I have write a sample code to fulfill it.

In HTML, add the datagrid into a table and set its width and height to
100%, like this:

<TABLE id="Table1" align="center" style="WIDTH: 464px; HEIGHT: 208px"
cellSpacing="0" cellPadding="0"
width="464" border="1" borderColor="#ff3366">
<TR>
<TD style="HEIGHT: 29px" align="center" colSpan="8">Official Impact
Summary</TD>
</TR>
<TR>
<TD style="WIDTH: 19.97%; HEIGHT: 107px" align="center"
colSpan="2">abcdefg</TD>
<TD style="WIDTH: 37.5%; HEIGHT: 107px" align="center" colSpan="3">Program
Totals</TD>
<TD style="WIDTH: 37.5%; HEIGHT: 107px" align="center"
colSpan="3">Official Totals</TD>
</TR>
<TR>
<TD style="HEIGHT: 29px" align="center" colSpan="8">
<asp:DataGrid id="DataGrid1" runat="server" Width="100%"
Height="100%"></asp:DataGrid></FONT>
</TD>
</TR>
</TR>
</TABLE>

Then when you bind the data to the datagrid, it will generate what you want:

SqlDataAdapter adapter=new SqlDataAdapter("select * from
jobs","server=localhost;database=pubs;uid=sa;pwd=" );
DataSet ds=new DataSet();
adapter.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();

If you still can not produce out, I will attach my project for you.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Billy Jacobs" <bi********@csa.com>
| Sender: "Billy Jacobs" <bi********@csa.com>
| References: <04****************************@phx.gbl>
<x$**************@cpmsftngxa07.phx.gbl>
<0b****************************@phx.gbl>
<l#**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Headers in Datagrid spanning multiple columns.
| Date: Fri, 19 Sep 2003 05:01:57 -0700
| Lines: 26
| Message-ID: <06****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN+pdNdTL/p2eRNSV6WuLXcNj+doQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:109156
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Sorry I meant that I need the headers to span a certain
| number of columns as described here.
|
| I want to accomplish the following except with a datagrid.
|
| <Table>
| <tr>
| <td colspan=8>Official Impact Summary</td>
| </tr>
| <tr>
| <td colspan=2></td>
| <td colspan=3>Program Totals</td>
| <td colspan=3>Official Totals</td>
| </tr>
| <tr> 'Here would be my bound rows.
| <td>Col1Info</td><td>Col2Info</td><td>Col3Info</td>
| <td>Col4Info</td><td>Col5Info</td><td>Col6Info</td>
| <td>Col7Info</td><td>Col8Info</td>
| </tr>
| <tr>...</table>
|
|
| Thanks,
|
| Billy Jacobs
|
|

Jul 21 '05 #6

P: n/a
Well this doesn't work. Even at design time the width of
the parent table columns are different than those of the
datagrid. So my column headers that span multiple columns
don't span the columns correctly.

Billy Jacobs.
-----Original Message-----

Hi Billy,

I think what I originally suggested is a suitable solution.I have write a sample code to fulfill it.

In HTML, add the datagrid into a table and set its width and height to100%, like this:

<TABLE id="Table1" align="center" style="WIDTH: 464px; HEIGHT: 208px"cellSpacing="0" cellPadding="0"
width="464" border="1" borderColor="#ff3366">
<TR>
<TD style="HEIGHT: 29px" align="center" colSpan="8">Official ImpactSummary</TD>
</TR>
<TR>
<TD style="WIDTH: 19.97%; HEIGHT: 107px" align="center"colSpan="2">abcdefg</TD>
<TD style="WIDTH: 37.5%; HEIGHT: 107px" align="center" colSpan="3">ProgramTotals</TD>
<TD style="WIDTH: 37.5%; HEIGHT: 107px" align="center"colSpan="3">Official Totals</TD>
</TR>
<TR>
<TD style="HEIGHT: 29px" align="center" colSpan="8"> <asp:DataGrid id="DataGrid1" runat="server" Width="100%"Height="100%"></asp:DataGrid></FONT>
</TD>
</TR>
</TR>
</TABLE>

Then when you bind the data to the datagrid, it will generate what you want:
SqlDataAdapter adapter=new SqlDataAdapter("select * from
jobs","server=localhost;database=pubs;uid=sa;pwd= ");
DataSet ds=new DataSet();
adapter.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();

If you still can not produce out, I will attach my project for you.
Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Billy Jacobs" <bi********@csa.com>
| Sender: "Billy Jacobs" <bi********@csa.com>
| References: <04****************************@phx.gbl>
<x$**************@cpmsftngxa07.phx.gbl>
<0b****************************@phx.gbl>
<l#**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Headers in Datagrid spanning multiple columns.| Date: Fri, 19 Sep 2003 05:01:57 -0700
| Lines: 26
| Message-ID: <06****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN+pdNdTL/p2eRNSV6WuLXcNj+doQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:109156| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Sorry I meant that I need the headers to span a certain| number of columns as described here.
|
| I want to accomplish the following except with a datagrid.|
| <Table>
| <tr>
| <td colspan=8>Official Impact Summary</td>
| </tr>
| <tr>
| <td colspan=2></td>
| <td colspan=3>Program Totals</td>
| <td colspan=3>Official Totals</td>
| </tr>
| <tr> 'Here would be my bound rows.
| <td>Col1Info</td><td>Col2Info</td><td>Col3Info</td>
| <td>Col4Info</td><td>Col5Info</td><td>Col6Info</td>
| <td>Col7Info</td><td>Col8Info</td>
| </tr>
| <tr>...</table>
|
|
| Thanks,
|
| Billy Jacobs
|
|

.

Jul 21 '05 #7

P: n/a

Hi Billy,

At design time, you add the datagrid into the table's bottom cell, then
after
setting the datagrid's width and height to 100%, the datagrid should fill
in the
cell.

I have attached my project in this post.This project uses the sql server's
default database to fill the datagrid.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Billy Jacobs" <bi********@csa.com>
| Sender: "Billy Jacobs" <bi********@csa.com>
| References: <04****************************@phx.gbl>
<x$**************@cpmsftngxa07.phx.gbl>
<0b****************************@phx.gbl>
<l#**************@cpmsftngxa06.phx.gbl>
<06****************************@phx.gbl>
<rR**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Headers in Datagrid spanning multiple columns.
| Date: Thu, 25 Sep 2003 20:09:32 -0700
| Lines: 131
| Message-ID: <00****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOD25uruhFelYH7TJSa+XyfQDgtjA==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:109972
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Well this doesn't work. Even at design time the width of
| the parent table columns are different than those of the
| datagrid. So my column headers that span multiple columns
| don't span the columns correctly.
|
| Billy Jacobs.
|
| >-----Original Message-----
| >
| >Hi Billy,
| >
| >I think what I originally suggested is a suitable
| solution.
| >I have write a sample code to fulfill it.
| >
| >In HTML, add the datagrid into a table and set its width
| and height to
| >100%, like this:
| >
| ><TABLE id="Table1" align="center" style="WIDTH: 464px;
| HEIGHT: 208px"
| >cellSpacing="0" cellPadding="0"
| >width="464" border="1" borderColor="#ff3366">
| ><TR>
| > <TD style="HEIGHT: 29px" align="center"
| colSpan="8">Official Impact
| >Summary</TD>
| ></TR>
| ><TR>
| > <TD style="WIDTH: 19.97%; HEIGHT: 107px"
| align="center"
| >colSpan="2">abcdefg</TD>
| > <TD style="WIDTH: 37.5%; HEIGHT: 107px"
| align="center" colSpan="3">Program
| >Totals</TD>
| > <TD style="WIDTH: 37.5%; HEIGHT: 107px"
| align="center"
| >colSpan="3">Official Totals</TD>
| ></TR>
| ><TR>
| > <TD style="HEIGHT: 29px" align="center"
| colSpan="8">
| > <asp:DataGrid id="DataGrid1" runat="server"
| Width="100%"
| >Height="100%"></asp:DataGrid></FONT>
| > </TD>
| ></TR>
| ></TR>
| ></TABLE>
| >
| >Then when you bind the data to the datagrid, it will
| generate what you want:
| >
| >SqlDataAdapter adapter=new SqlDataAdapter("select * from
| >jobs","server=localhost;database=pubs;uid=sa;pwd= ");
| >DataSet ds=new DataSet();
| >adapter.Fill(ds);
| >DataGrid1.DataSource=ds;
| >DataGrid1.DataBind();
| >
| >If you still can not produce out, I will attach my
| project for you.
| >
| >Hope this helps,
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Billy Jacobs" <bi********@csa.com>
| >| Sender: "Billy Jacobs" <bi********@csa.com>
| >| References: <04****************************@phx.gbl>
| ><x$**************@cpmsftngxa07.phx.gbl>
| ><0b****************************@phx.gbl>
| ><l#**************@cpmsftngxa06.phx.gbl>
| >| Subject: RE: Headers in Datagrid spanning multiple
| columns.
| >| Date: Fri, 19 Sep 2003 05:01:57 -0700
| >| Lines: 26
| >| Message-ID: <06****************************@phx.gbl>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| Thread-Index: AcN+pdNdTL/p2eRNSV6WuLXcNj+doQ==
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Newsgroups: microsoft.public.dotnet.general
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.general:109156
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.public.dotnet.general
| >|
| >| Sorry I meant that I need the headers to span a
| certain
| >| number of columns as described here.
| >|
| >| I want to accomplish the following except with a
| datagrid.
| >|
| >| <Table>
| >| <tr>
| >| <td colspan=8>Official Impact Summary</td>
| >| </tr>
| >| <tr>
| >| <td colspan=2></td>
| >| <td colspan=3>Program Totals</td>
| >| <td colspan=3>Official Totals</td>
| >| </tr>
| >| <tr> 'Here would be my bound rows.
| >| <td>Col1Info</td><td>Col2Info</td><td>Col3Info</td>
| >| <td>Col4Info</td><td>Col5Info</td><td>Col6Info</td>
| >| <td>Col7Info</td><td>Col8Info</td>
| >| </tr>
| >| <tr>...</table>
| >|
| >|
| >| Thanks,
| >|
| >| Billy Jacobs
| >|
| >|
| >
| >.
| >
|

Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.