473,396 Members | 2,020 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,396 software developers and data experts.

DataList not keeping some of its attributes.

I have a DataList where I am trying to set the background color to
particular DataListItems:

Dim oDLI as DataListItem = s.parent.parent
oDLI.BackColor = System.Drawing.Color.Green

This works fine.

The problem is that on any PostBack, the color is gone (empty).

The DataGrid doesn't seem to have this problem. I can set a DataGridItem
and it will stay that way unless I rebind to it.

This is similar to another problem I had setting the visible attribute
(doesn't work) for the DataListItem.

Is there a setting or something that I can set that will tell it to keep the
attribute setting?

The only other way I can figure is to set an invisible label on the
datalistitem that is nothing more than yes/no whether the color should be
there or not and I can reset it during Page_Load.

That's just a little more work than I would have thought I would have to do.

Thanks,

Tom
Nov 19 '05 #1
1 1133
I actually found a better way to solve the problem (which I believe will
solve my visibility problem).
The datalistitem is what seems to have the problem (unlike the datagriditem
which seems to work fine). What seems to solve the problem is to put an
asp:panel around it all:

************************************************** **************************************
<itemtemplate>
<asp:Panel id="thePanel" runat="server">
<table border="0" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0">
<tr>
<td>
<asp:label id="lblQuestion" Text='<%#
DataBinder.Eval(Container.DataItem, "Question") %>' runat="server" />
</td>
<td width="40px">
<asp:LinkButton Text="Move" ID="btnMove"
OnClick="SetMoveList_Click" runat="server" />
</td>
</tr>
</table>
</asp:Panel>
</itemtemplate>
************************************************** ***************************************

You then can change the color of the panel which will color the whole row.
It will also solve the class problem I mentioned in the other post as well
where if you set the alternatingitemstyle to a CSSClass for the backcolor,
you can't set the color programmatically. Instead of change the color of
the datalistitem, you change the color of the panel.

Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
I have a DataList where I am trying to set the background color to
particular DataListItems:

Dim oDLI as DataListItem = s.parent.parent
oDLI.BackColor = System.Drawing.Color.Green

This works fine.

The problem is that on any PostBack, the color is gone (empty).

The DataGrid doesn't seem to have this problem. I can set a DataGridItem
and it will stay that way unless I rebind to it.

This is similar to another problem I had setting the visible attribute
(doesn't work) for the DataListItem.

Is there a setting or something that I can set that will tell it to keep
the attribute setting?

The only other way I can figure is to set an invisible label on the
datalistitem that is nothing more than yes/no whether the color should be
there or not and I can reset it during Page_Load.

That's just a little more work than I would have thought I would have to
do.

Thanks,

Tom

Nov 19 '05 #2

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

Similar topics

7
by: Steve Klett | last post by:
I would like to have DHTML on my DataList so that when I hover over a cell, it will change colors. I can't find a way to get onMouseOver into the generated <td> from a DataList. There must be ...
1
by: Steve Klett | last post by:
Hi- Is there anyone that knows or maybe even a MS person that would like to discuss workarounds for the DataList not respecting Attributes.Add() I need to get onMouseOver and onMouseLeave into...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
5
by: Ryan Moore | last post by:
I am trying to modify the onMouseOver attribute of a <td> cell created by a DataList... according to ...
2
by: Fabiano | last post by:
Please, i need to hide a Item(Collumn) of a DataList that is inside of another DataList based on some data that i my database returns. For a sample i created the code above, but it doesn't work....
1
by: WB | last post by:
Hi, I would like to do something like this page: http://www.stocklayouts.com/Products/Postcard/Postcard-Template-Design-Library.aspx?kwid=38 Notice when you mouse-over any of the icons under...
3
by: rn5a | last post by:
I want to change the background color of a row in a DataList when the mouse is moved over a row. This is how I tried but it doesn't change the background color of a row in the DataList when the...
1
by: obs | last post by:
Hi. I'm using the following code to change a hyperlink attributes of a hyperlink which is located in an itemtemplate of a datalist. When I debug it the attributes are changed and everything is...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
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?
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
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...
0
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,...
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
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...

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.