asp:templatefield question (please help)

  • Thread starter Thread starter Mat
  • Start date Start date
M

Mat

<asp:TemplateField HeaderText="Column 1">
<ItemStyle />
<ItemTemplate>
<asp:Label ID="LabelEnterprise" Text='Label1' runat="server" />
<br/>
<asp:Label ID="LabelHostedByWebsite" Text='Label2' runat="server" />
</ItemTemplate>
</asp:TemplateField>


as you could see there is a <br/> tag between the 2 labels so id like to
change row for the next label to show on the next line.

how come it does not work. the labels are next to each other.

is there a way to show the label2 on the next line?
 
Not sure how should a <br /> behave inside template. The standard way is to
use a table:

<ItemTemplate>
<table><tr><td>
<asp:Label ID="LabelEnterprise" Text='Label1' runat="server" />
</td></tr>
<tr><td>
<asp:Label ID="LabelHostedByWebsite" Text='Label2' runat="server" />
</td></tr></table>
</ItemTemplate>
 
actually i tried <br/> again and it works
dont know why it did not work on first time... strange

Eliyahu Goldin said:
Not sure how should a <br /> behave inside template. The standard way is
to use a table:

<ItemTemplate>
<table><tr><td>
<asp:Label ID="LabelEnterprise" Text='Label1' runat="server" />
</td></tr>
<tr><td>
<asp:Label ID="LabelHostedByWebsite" Text='Label2' runat="server" />
</td></tr></table>
</ItemTemplate>


--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Mat said:
<asp:TemplateField HeaderText="Column 1">
<ItemStyle />
<ItemTemplate>
<asp:Label ID="LabelEnterprise" Text='Label1' runat="server" />
<br/>
<asp:Label ID="LabelHostedByWebsite" Text='Label2' runat="server" />
</ItemTemplate>
</asp:TemplateField>


as you could see there is a <br/> tag between the 2 labels so id like to
change row for the next label to show on the next line.

how come it does not work. the labels are next to each other.

is there a way to show the label2 on the next line?
 
Back
Top