Solved

Have multiple lines (or rows) in header in DataGrid - C#

Posted on 2004-09-17
11
286 Views
Last Modified: 2012-05-05
Hi,

Question...
How can I have multiple lines (or rows) in header in DataGrid?
For example, I want to display like...

                           |       Quantity Sold       |      Quantity Available   |
Product | Customer | Date1 | Date2 | Date3 | Date1 | Date2 | Date3 |

Thanks for your help!

bigbridge
0
Comment
Question by:bigbridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
11 Comments
 
LVL 11

Expert Comment

by:raj3060
ID: 12086907
Easy,
<table border="1" align="center">
<tr>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td>Quantity Sold</td>
<td>Quantity Available</td>
</tr>
<tr>
<td>Product</td>
<td>Customer</td>
<td>
<table>
<tr>
<td>Date1</td>
<td>Date2</td>
<td>Date3</td>
</tr></table>
</td>
<td>
<table>
<tr>
<td>Date1</td>
<td>Date2</td>
<td>Date3</td>
</tr></table>
</td>
</tr>
</table>

--Raj
0
 
LVL 11

Expert Comment

by:raj3060
ID: 12086964
Here is another way to do it:

<table cellspacing="0" cellpadding="0" border="1" align="center">
<tr>
<td>Product</td>
<td>Customer</td>
<td>
<table cellspacing="0" cellpadding="0" border="1" align="center">
<tr>
<td colspan="3" align="center">Quantity Sold</td>
</tr>
<tr>
<td>Date1</td>
<td>Date2</td>
<td>Date3</td>
</tr></table>
</td>
<td>
<table cellspacing="0" cellpadding="0" border="1" align="center">
<tr>
<td colspan="3" align="center">Quantity Available</td>
</tr>
<tr>
<td>Date1</td>
<td>Date2</td>
<td>Date3</td>
</tr></table>
</td>
</tr>
</table>
0
 

Author Comment

by:bigbridge
ID: 12086966
I am using DataGrid in .NET...
I wish I could just use the table though :)
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 11

Accepted Solution

by:
raj3060 earned 125 total points
ID: 12087393
Here are some resources for tasks similar to yours:

http://www.dotnet247.com/247reference/System/Windows/Forms/DataGrid/__discussions/130

Hope this helps
0
 

Author Comment

by:bigbridge
ID: 12087465
I still can't find the solution...
0
 
LVL 1

Expert Comment

by:Roger3
ID: 12088930
From your original post, I assume you already have a datasource specified for the datatable?

Try this...

<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
      <Columns>
            <asp:TemplateColumn HeaderText="Quantity Sold">
                  <ItemTemplate>
                        <table cellpadding="0" cellspacing="0">
                              <tr>
                                    <td nowrap>
                                          <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Date1") %>' Width="40" ID="Label1"></asp:Label>
                                          <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Date2") %>' Width="40" ID="Label2"></asp:Label>
                                          <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Date3") %>' Width="40" ID="Label3"></asp:Label>
                                    </td>
                              </tr>
                        </table>
                  </ItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Quantity Available">
                  <ItemTemplate>
                        <table cellpadding="0" cellspacing="0">
                              <tr>
                                    <td nowrap>
                                          <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Date1") %>' Width="40" ID="Label4"></asp:Label>
                                          <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Date2") %>' Width="40" ID="Label5"></asp:Label>
                                          <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Date3") %>' Width="40" ID="Label6"></asp:Label>
                                    </td>
                              </tr>
                        </table>
                  </ItemTemplate>
            </asp:TemplateColumn>
      </Columns>
</asp:DataGrid>

note: I added the table inside the template to allow you to specify 'nowrap' on the <TD>

Please let us know if you have other questions,

Roger
0
 
LVL 1

Assisted Solution

by:Roger3
Roger3 earned 125 total points
ID: 12221486
Did you get what you needed?

Thanks,
Roger
0
 
LVL 11

Expert Comment

by:raj3060
ID: 12515032
Point split
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question