What with my interval here? When the labels contain text, the spacing is OK, but then they are empty, they have a space between each label. Why is extra space added when labels contain empty text?
With the text in the labels (how I want it to look): 
Without the text in the shortcuts (as I don't want it to look): 
In the C # code behind:
// On page load for (int i = 1; i < 10; i++) { string ID = i.ToString(); PopulateLastNameLabel(ID); } protected void PopulateLastNameLabel(string ID) { Label lbl = new Label(); lbl.Width = 70; lbl.Height = 20; lbl.Text = ""; lbl.BackColor = System.Drawing.Color.Red; lbl.ID = "lastname_" + ID; pnlLastNameLabel.Controls.Add(lbl); }
From ASP.NET:
<asp:Table ID="tblDisplayTable" runat="server"> <asp:TableRow> <asp:TableCell> <asp:Panel ID="pnlPrizeNumberLabel" runat="server" Width="80px"></asp:Panel> </asp:TableCell> <asp:TableCell HorizontalAlign="Center" VerticalAlign="Middle"> <asp:Panel ID="pnlPrizeDropDownList" runat="server" Width="130px"></asp:Panel> </asp:TableCell> <asp:TableCell> <asp:Panel ID="pnlNickNameLabel" runat="server" Width="70px"></asp:Panel> </asp:TableCell> <asp:TableCell> <asp:Panel ID="pnlPrizeNicknameTextBox" runat="server" Width="125px"></asp:Panel> </asp:TableCell> <asp:TableCell> <asp:Panel ID="pnlFirstNameLabel" runat="server" Width="70px"></asp:Panel> </asp:TableCell> <asp:TableCell> <asp:Panel ID="pnlLastNameLabel" runat="server" Width="70px"></asp:Panel> </asp:TableCell> <asp:TableCell> <asp:Panel ID="pnlEmailAddressLabel" runat="server" Width="140px"></asp:Panel> </asp:TableCell> <asp:TableCell> <asp:Panel ID="pnlAddButton" runat="server" Width="40px"></asp:Panel> </asp:TableCell> </asp:TableRow> </asp:Table>
source share