Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-17
11
Medium Priority
?
290 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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Accepted Solution

by:
raj3060 earned 500 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

926 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