473,414 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Format DataList

I am using a DataList control to display records from a database table.
The records are being rendered in a HTML table which is within the
DataList....something like this:

<form runat="server">
<asp:DataList ID="dlItem" AlternatingItemStyle-BackColor="lavender"
ItemStyle-BackColor="pink" runat="server">

<HeaderTemplate>
<table width="100%">
<tr>
<th>PRODUCT</th>
<th>PRICE</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%# Container.DataItem("Name") %></td>
<td><%# Container.DataItem("Price") %></td>
</tr>
</ItemTemplate>

<FooterTemplate>
<tr>
<td><b>Some Text Goes Here</b></td>
</tr>
</table>
</FooterTemplate>

</asp:DataList>
</form>

Now what I find is though the DataList displays the records, the
AlternatingItemStyle-BackColor & ItemStyle-BackColor properties that I
have set within the DataList tag don't render the back color of the
rows with the colors that I have specified. In other words, the back
color of the rows aren't set to lavender & pink alternately; rather the
back color of all the rows remain white.

Is it because I am using HTML table within the DataList control? If so,
how do I format the rows in a DataList under such circumstances?

Oct 1 '06 #1
2 2036
I've come across this behaviour too when using HTML table objects in a
DataList template. It is the default back colour of the table that is
rendered rather than that of the template.

I presume the table is there to control positioning within the
template. On the occasion when I did this I ended up abandoning this
method in favour of setting the width and height of the databound
labels to effect positioning because with the table they wouldn't line
properly with the the header.

If you need to use a table and don't want the back color to dominate,
try setting the back color of the table to transparent.

Good luck

Oct 2 '06 #2
I tried setting the background color of the table to transparent like
this:

<asp:DataList ID="dlYourCart" AlternatingItemStyle-BackColor="lavender"
ItemStyle-BackColor="pink" runat="server">
<HeaderTemplate>
<table bordercolor="black" cellspacing="0" class="format" width="100%"
style="background-image: none; background-color: transparent;">

but that doesn't make any difference - the background-color of the
entire table still remains white.

Any other ideas?

Never thought that formatting a DataList would be such a pain in the
wrong place!
Phil H wrote:
I've come across this behaviour too when using HTML table objects in a
DataList template. It is the default back colour of the table that is
rendered rather than that of the template.

I presume the table is there to control positioning within the
template. On the occasion when I did this I ended up abandoning this
method in favour of setting the width and height of the databound
labels to effect positioning because with the table they wouldn't line
properly with the the header.

If you need to use a table and don't want the back color to dominate,
try setting the back color of the table to transparent.

Good luck
Oct 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: lianfe_ravago | last post by:
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the...
5
by: IGotYourDotNet | last post by:
I'm pulling data out of an oracle db and populating a datagrid such as this cars doors Cylinders chevy 4 6 ford 2 8 how can i make it such as cars ...
0
by: IGotYourDotNet | last post by:
I have a datalist and I need to change the text in the header section of the datalist The data is coming out such as 1 2 3 4 5 6 and if it equals 5 or 6 i need it to say OT instead of 5 or 6. How...
8
by: bienwell | last post by:
Hi, I have a problem of displaying data bound by a datalist control. In my table, I have a field Start_date which has Short Date data type. I tried to update this field by Current Date. After...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
3
by: staeri | last post by:
I'm trying to export a datalist to Excel with this code: Response.Clear() Response.Buffer = True Response.Charset = "" Response.ContentType = "application/vnd.ms-excel" Me.EnableViewState =...
0
by: JP | last post by:
I have an issue with the DataList control. Im using vertical format with repeat column set to a value of 3 The control contains both images and text. The issue is that even though all the...
2
by: Mywork60 | last post by:
Hi every body I use a datalist in my web form , but I can't format paragraphs and break lines in datalist items
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.