• 0

[ASP.NET 3.5] Suggestion on GridView look.


Question

Hello,

I have this Gridview:

post-98644-1261054321.jpg

post-98644-1261054330.jpg

This is the code:

For the header:

protected void Page_Load(object sender, EventArgs e)

{

this.GridView1.HeaderRow.Cells[0].Text = "Edit";

Table table = new Table() { CellSpacing = 4 };

TableRow row = new TableRow();

table.Rows.Add(row);

table.Rows[0].Cells.Add(new TableCell() { Text = "Client name" });

table.Rows[0].Cells.Add(new TableCell() { Text = "Order List Name" });

table.Rows[0].Cells.Add(new TableCell() { Text = "Created Date" });

table.Rows[0].Cells.Add(new TableCell() { Text = "Status" });

table.Rows[0].Cells.Add(new TableCell() { Text = "Estimated Shipping Date" });

table.Rows[0].Cells.Add(new TableCell() { Text = "View Details" });

this.GridView1.HeaderRow.Cells[1].Controls.Add(table);

}

For the grid:

<asp:GridView ID="GridView1" runat="server" AllowPaging="False" CellPadding="4" ForeColor="#333333"

GridLines="Both" DataKeyNames="SubPOID" AutoGenerateColumns="False"

DataSourceID="SqlDataSource2" Visible="true" onrowcommand="GridView1_RowCommand">

<RowStyle BackColor="#EFF3FB" />

<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

<EditRowStyle BackColor="#F7F6F3" />

<AlternatingRowStyle BackColor="White" />

<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

<Columns>

<asp:CommandField ShowEditButton="True" ItemStyle-VerticalAlign="Top" />

<asp:TemplateField>

<ItemTemplate>

<table style="width: 100%;" cellpadding="0" cellspacing="0">

<tr>

<td>

<asp:HiddenField ID="hidden_fld" runat="server" Value='' />

<asp:Label ID="Label2" runat="server" Text=''></asp:Label>

</td>

<td>

<asp:Label ID="Label4" runat="server" Text=''></asp:Label>

</td>

<td>

<asp:Label ID="Label3" runat="server" Text=''></asp:Label>

</td>

<td>

<asp:Label ID="Label1" runat="server" Text=''></asp:Label>

</td>

<td>

<asp:Label ID="Label112" runat="server" Text=''></asp:Label>

</td>

<td valign="top">

<asp:Button ID="Button2" runat="server" Text="View Details" OnClick="Button2_Click" />

</td>

</tr>

////.....ETC...../////

As you can see, the look is completely messed up. How do I organize it? AT LEAST, I need the header and the content to match together (same width ... etc ...). Any ideas ;( ?

Thanks.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Technically, you can't. The cells for each row are bound to the width of the header. And, the width of the header assumes the size of the largest cell (if larger than header). In this case I would rename "Confirmed Quantity" to "# Confirmed" to shorten the column. Then also align the text left. You'll see a better improvement.

Edited by Rohdekill
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.