asp:templatefield question (please help)

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?
 
E

Eliyahu Goldin

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>
 
M

Mat

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top