formatting a datalist into columns? Please Help

M

Moe Sizlak

Hi There,

I am wanting to format a datalist into columns, so do I need to use a table
rows & columns? or can I use templates and a property at the top of the list
itself ? It seems that when I try to format the datalist I can't get it to
look like a normal html table.

Moe

col1 col2 col3 col4 col 5


<asp:DataList id="modify_listings"
runat="server"
headerstyle-font-name="Verdana"
cellpadding="10"
cellspacing="10"
GridLines="Both"
headerstyle-font-size="12pt"
headerstyle-horizontalalign="center"
headerstyle-font-bold="true"
itemstyle-backcolor="#778899"
itemstyle-forecolor="#ffffff"
footerstyle-font-size="9pt"
footerstyle-font-italic="true"
ShowHeader="true">

<HeaderTemplate>

<b> List</b>


</HeaderTemplate>

<ItemTemplate>

<asp:HyperLink id="HyperLink3"
style="font-size:xxsmall" Text='Modify' NavigateUrl='<%#
"edit_listings.aspx?ListingID=" & DataBinder.Eval(Container.DataItem,
"ListingID")%>' runat="server" /><br />

<%# DataBinder.Eval(Container.DataItem,
"listprice","{0:c}")%><br />

<%# DataBinder.Eval(Container.DataItem,
"manufacturer") %><br />

<%# DataBinder.Eval(Container.DataItem,
"listeddate","{0:dd-MM-yy}") %><br />

<%# DataBinder.Eval(Container.DataItem,
"formname") %><br />
<%# DataBinder.Eval(Container.DataItem,
"status") %><br />
<asp:HyperLink id="HyperLink1"
style="font-size:xxsmall" Text='Item Sold?' NavigateUrl='<%#
"processrequest.aspx?I=1&ListingID=" & DataBinder.Eval(Container.DataItem,
"ListingID")%>' runat="server" />

</ItemTemplate>
</asp:DataList>
 
G

Guest

Hi Moe

Since u are using multiple items in your itemtemplate all of then will be displayed in a single row and single column.
For tabular look and feel u will have to use the datagrid control. If u still want to use the datalist add the </TD> tag after each item except the last and <TD> before each item except the first item in the itemtemplate. This will format the data as a table.
 
M

Marina

I think u will not be able to accomplish this with the datalist. The
datalist generates a table, into which it places your item templates, etc.
So anything you would do inside the templates, would wind up overlapping
with something the datalist generates, and I don't think you could get a
table out of it.

You could use the datagrid, if u really looking for an html table - that's
what the grid is for.

You could also use a repeater. Unlike the datalist, the repeater does not
generate any html table elements around its items. It generates everything
as is - so you can put a <table> tag in the header, a </table> in the
footer, and then appropriate html in the item template, for the
rows/columns.
 

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