Formatting a DataList ItemTemplate using CSS

N

Nathan Sokalski

I have a DataList with the following ItemStyle and ItemTemplate:

<ItemStyle VerticalAlign="Top"/>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Label1" Width="300px"
style="word-wrap:normal;"/>
<asp:Label ID="Label2" runat="server" Text="Label2"
style="float:left;word-wrap:break-word;"/>
<asp:Button ID="Button1" runat="server" Text="Button1" style="float:right;"
Width="125px"/>
</ItemTemplate>

I want the output to be similar to the following:

Label1 Label2 Label2 Label2
Label2 Label2 Button1
Label2 Label2
Label2 Label2 Label2
Label2 Label2
Label2 Label2 Label2
Label2 Label2
Label2 Label2 Label2
Label2 Label2
Label2

What this is is a fixed-width label, a variable-width label that might wrap,
and a button. I want the variable-width label to take up the space between
the fixed-width label and the button, and I want the button to always be
right-aligned. What would be the best way to do this in an asp:DataList's
ItemTemplate? Thanks.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top