473,769 Members | 2,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

alternating item bgcolor in datalist with 2 columns

I'm trying to set alternating bgcolor for a datalist with 2 columns. My
problem is that its the alternating cell that get the bgcolor, not the row.
Is it possible to set alternating color of rows?

Here is my code:

<asp:DataList id=dlKommuner runat="server" Width="400px"
RepeatColumns=" 2" CellPadding="3" >
<AlternatingIte mStyle Width="200px" CssClass="arow" >
</AlternatingItem Style>

<ItemStyle Width="200px">
</ItemStyle>

<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Name" ) %>' ID="Label2"></asp:Label>

</ItemTemplate>

</asp:DataList>
Eirik Eldorsen
Nov 18 '05 #1
1 4677
Erik,

You can't use alternating item styles to achieve what you want for the
following reason.

As far as datasource is concerned, datalist has only one column. With using
RepeatColumns=2 you are just arranging the same data column into 2 columns
on the screen. The notion of "AlternatingIte m" refers to every second record
coming from the datasource. In your case you are putting every second record
in another column. That's what you get.

Now, what you should do is to get rid of alternating item styles and use
code-behind PreRender event. In the event handler loop through the datalist
rows and set another background color for every second couple of records.

Eliyahu

"Eirik Eldorsen" <ku*******@hotm ail.com> wrote in message
news:V9******** ************@ne ws.telia.no...
I'm trying to set alternating bgcolor for a datalist with 2 columns. My
problem is that its the alternating cell that get the bgcolor, not the row. Is it possible to set alternating color of rows?

Here is my code:

<asp:DataList id=dlKommuner runat="server" Width="400px"
RepeatColumns=" 2" CellPadding="3" >
<AlternatingIte mStyle Width="200px" CssClass="arow" >
</AlternatingItem Style>

<ItemStyle Width="200px">
</ItemStyle>

<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Name" ) %>' ID="Label2"></asp:Label>

</ItemTemplate>

</asp:DataList>
Eirik Eldorsen

Nov 18 '05 #2

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

Similar topics

12
2894
by: LRW | last post by:
Is there some way to make a table have alternating colors for rows when you're generating the table data with a WHILE statement? You know, row 1 has a gray BG, row 2 is white, row 3 is gray, 4 is white, etc, for as long as there's data. Here's what I'm using right now: $query_RSwho = "SELECT * FROM tbl_indv ORDER BY name ASC"; $RSwho = @mysql_query($query_RSwho, $connection) or die("Couldn't query: " .. mysql_error()); while...
1
1831
by: Newton | last post by:
I know how to alternate table row bgcolor by odd/even method but what I am trying to acheive is alternate colors by the date value in the database so that each row with the same date value has the same bgcolor. There maybe 3 red rows for 1st date, then 2 blue rows for 2nd date, then 6 red rows for next date etc. I have no idea where to start, any suggestions?
0
3115
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format. However, the DataGrid begins to get very cumbersome as the number of columns of data you present increases. Anything more than half a dozen columns or so and you probably induce horizontal scrolling - a real no-no for me. If you put such a...
0
1248
by: MattC | last post by:
Hi, I have place the following code in my ItemDataBound event: The problem I have is that when I select a row for editing using the edit command it no longer changes the CSSClass to the one specified in SelectedItemStyle. TIA
1
2940
by: lydia sista via DotNetMonster.com | last post by:
hi! help... How do you show/hide item's data? Like sale item on product catalogue. I want to show the sale image when the status of product is on sale. in my catalogue I use datalist: ------------------------------------------------------------------ <ASP:DataList id="MyDataList" RepeatColumns="3" runat="server"> <ItemTemplate> <table cellpadding="0" cellspacing="0">
9
2695
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to perform updates. All the styles that are set are being followed by all templated columns with the exception for the update column. The update column does set the BackColor appropriately but when setting its ForeColor the LinkButton's color is blue and...
2
2300
by: craigkenisston | last post by:
Is that possible ? Choose alternate item, just to change color, I mean, not having to totally copy all the item content in both the Item and the AlternateItem. I tried to do this by adding a div with different background color, but the DataList acts like if that code were not there.
5
3346
by: | last post by:
I'm making admin forms. I'm wondering if there is a way to have the server programmatically assign alternating colors in a regular table (not a datalist control). I notice ASP.NET 2 offers a runat="server" attribute on tables, leading me to believe that this should be possible. Any ideas? I'm using C#. Thanks, -KF
4
7810
by: rn5a | last post by:
A DataList displays 3 columns - Product, Category & Price. These columns are populated with records from a SQL Server 2005 DB table. Apart from the above 3 DB columns that the resultset retrieves, there is another DB column named 'Description'. Though the resultset fetches this column as well along with the above 3 columns, I am excluding the Description column from the DataList - the reason being most of the descriptions are pretty long &...
0
9579
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
10038
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...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
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
7404
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
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.