473,766 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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....som ething like this:

<form runat="server">
<asp:DataList ID="dlItem" AlternatingItem Style-BackColor="lave nder"
ItemStyle-BackColor="pink " runat="server">

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

<ItemTemplate >
<tr>
<td><%# Container.DataI tem("Name") %></td>
<td><%# Container.DataI tem("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
AlternatingItem Style-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 2051
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 " AlternatingItem Style-BackColor="lave nder"
ItemStyle-BackColor="pink " runat="server">
<HeaderTemplate >
<table bordercolor="bl ack" cellspacing="0" class="format" width="100%"
style="backgrou nd-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
768
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 error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 457: <tr>
5
1474
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 chevy ford cylinder 6 8
0
924
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 can i do that within a datalist? I've tried If e.Item.DataItem("period") = "5" Then e.Item.DataItem = "OT" End If
8
5891
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 that, I display End_Date on the DataList control. The output looks like 3/18/2005 12:00:00 AM . I'd like to format data for this field to be 3/18/2005. Please help me. Thanks in advance....
6
9595
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 only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
3
10303
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 (where is the child DataList).... But in case I want to make Edit in this child DataList it is not working... No edit template showed... :( this is a code that i use for the child DataList... Edit command // this is for child DataList...
3
5719
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 = False Dim sw As StringWriter = New StringWriter() Dim hw As HtmlTextWriter = New HtmlTextWriter(sw) DataList1.RenderControl(hw)
0
1107
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 images are 75 x 75 on there own line AND the lines of test below it are only one line, the repeated columns do not line up. Once column (or I should say <TD> tag in the column) may be slightly higher or lower then the adjacent column. Why wont they...
2
1169
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
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10008
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8833
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.