473,387 Members | 1,757 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,387 software developers and data experts.

Cannot dynamically assign a BackColor to a datalist

I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style

<HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>

....doesnot work as a Parser error renders: Content ('<HeaderStyle
BackColor=') does not match any properties within a
'System.Web.UI.WebControls.DataList', make sure it is well-formed

Jun 27 '08 #1
4 2179
Do it programatically. You can access the property directly from code as
follows:
assume the name of the datalist is dl

dl.HeaderStyle.BackColor = Color.Red;

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

".Net Sports" <ba********@cox.netwrote in message
news:1e**********************************@i36g2000 prf.googlegroups.com...
>I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style

<HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>

...doesnot work as a Parser error renders: Content ('<HeaderStyle
BackColor=') does not match any properties within a
'System.Web.UI.WebControls.DataList', make sure it is well-formed
Jun 27 '08 #2
Thanks for your response. There is no code behind in these scripts/
programs I am using. Inside the Datalist form block, I have:

<asp:DataList id="dlstCats" runat="server" RepeatColumns="4"
width="350px" ItemStyle-BackColor="#ccffcc" cellspacing="3">

<HeaderStyle BackColor="#008000"</HeaderStyle>
<HeaderTemplate<font class="body11-
wh">Providers for
<%= sregionZ %>: <%= Zonecustom() %></font</
HeaderTemplate>
<ItemTemplate><font class="body9bold-re"<a
href="re.aspx?zone=<%#Server.UrlEncode(Request.Que ryString("zone")) &
"&amp;cregion=" & Server.UrlEncode(Request.QueryString("cregion")) &
"&amp;category=" & (Eval("Category").ToString())%>">
<%# Eval("Category")%>
</a></font></ItemTemplate>
</asp:DataList>

as you see, I can provide dynamic variables from helper functions in
the headers of my page to stuff inside the Header Template & the
ItemTemplate, but I need to dynamically also change the HeaderStyle
BackColor property here
TIA
..netsports

On Apr 16, 5:39 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Do it programatically. You can access the property directly from code as
follows:
assume the name of the datalist is dl

dl.HeaderStyle.BackColor = Color.Red;

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

".Net Sports" <ballz2w...@cox.netwrote in message

news:1e**********************************@i36g2000 prf.googlegroups.com...
I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style
<HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
...doesnot work as a Parser error renders: Content ('<HeaderStyle
BackColor=') does not match any properties within a
'System.Web.UI.WebControls.DataList', make sure it is well-formed
Jun 27 '08 #3
Hi,

I suggest you wrap your HeaderTemplate content in a div and
dynamically assign a style to that element. Something like:

<HeaderTemplate>
<div style='background-color:<%= ssponcont %>' >
<font class="body11-wh">Providers for <%= sregionZ %>: <%=
Zonecustom() %></font>
<div>
</HeaderTemplate>

============
Regards,
Steve
www.stkomp.com

..Net Sports wrote:
Thanks for your response. There is no code behind in these scripts/
programs I am using. Inside the Datalist form block, I have:

<asp:DataList id="dlstCats" runat="server" RepeatColumns="4"
width="350px" ItemStyle-BackColor="#ccffcc" cellspacing="3">

<HeaderStyle BackColor="#008000"</HeaderStyle>
<HeaderTemplate<font class="body11-
wh">Providers for
<%= sregionZ %>: <%= Zonecustom() %></font</
HeaderTemplate>
<ItemTemplate><font class="body9bold-re"<a
href="re.aspx?zone=<%#Server.UrlEncode(Request.Que ryString("zone")) &
"&amp;cregion=" & Server.UrlEncode(Request.QueryString("cregion")) &
"&amp;category=" & (Eval("Category").ToString())%>">
<%# Eval("Category")%>
</a></font></ItemTemplate>
</asp:DataList>

as you see, I can provide dynamic variables from helper functions in
the headers of my page to stuff inside the Header Template & the
ItemTemplate, but I need to dynamically also change the HeaderStyle
BackColor property here
TIA
.netsports

On Apr 16, 5:39 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Do it programatically. You can access the property directly from code as
follows:
assume the name of the datalist is dl

dl.HeaderStyle.BackColor = Color.Red;

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

".Net Sports" <ballz2w...@cox.netwrote in message

news:1e**********************************@i36g2000 prf.googlegroups.com...
>I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style
<HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
...doesnot work as a Parser error renders: Content ('<HeaderStyle
BackColor=') does not match any properties within a
'System.Web.UI.WebControls.DataList', make sure it is well-formed
Jun 27 '08 #4
Hi,

I suggest you wrap your HeaderTemplate content in a div and
dynamically assign a style to that element. Something like:

<HeaderTemplate>
<div style='background-color:<%= ssponcont %>' >
<font class="body11-wh">Providers for <%= sregionZ %>: <%=
Zonecustom() %></font>
<div>
</HeaderTemplate>

============
Regards,
Steve
www.stkomp.com

..Net Sports wrote:
Thanks for your response. There is no code behind in these scripts/
programs I am using. Inside the Datalist form block, I have:

<asp:DataList id="dlstCats" runat="server" RepeatColumns="4"
width="350px" ItemStyle-BackColor="#ccffcc" cellspacing="3">

<HeaderStyle BackColor="#008000"</HeaderStyle>
<HeaderTemplate<font class="body11-
wh">Providers for
<%= sregionZ %>: <%= Zonecustom() %></font</
HeaderTemplate>
<ItemTemplate><font class="body9bold-re"<a
href="re.aspx?zone=<%#Server.UrlEncode(Request.Que ryString("zone")) &
"&amp;cregion=" & Server.UrlEncode(Request.QueryString("cregion")) &
"&amp;category=" & (Eval("Category").ToString())%>">
<%# Eval("Category")%>
</a></font></ItemTemplate>
</asp:DataList>

as you see, I can provide dynamic variables from helper functions in
the headers of my page to stuff inside the Header Template & the
ItemTemplate, but I need to dynamically also change the HeaderStyle
BackColor property here
TIA
.netsports

On Apr 16, 5:39 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Do it programatically. You can access the property directly from code as
follows:
assume the name of the datalist is dl

dl.HeaderStyle.BackColor = Color.Red;

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

".Net Sports" <ballz2w...@cox.netwrote in message

news:1e**********************************@i36g2000 prf.googlegroups.com...
>I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style
<HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
...doesnot work as a Parser error renders: Content ('<HeaderStyle
BackColor=') does not match any properties within a
'System.Web.UI.WebControls.DataList', make sure it is well-formed
Jun 27 '08 #5

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

Similar topics

0
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access...
2
by: Wee Bubba | last post by:
the lower part of my page consists of a dataList along with other server controls and HTML markup. this is my data display section. the upper part of my page is a data entry section. what I want...
2
by: stb | last post by:
Hi. Is it possible to write inline Templates for a DataList dynamically in the HTML code, based on the DataSet that is bound to the DataList? Anyone know how?
0
by: Gaurav Gargate | last post by:
Hi Group, I am creating a ASP.NET (C#) project. I am creating a datalist with some dynamically generated text boxes in the edit template. I have the datalist control on the form. The text box...
0
by: Sourav Dutta Gupta | last post by:
How can I set the BackColor of an ImageButton dynamically. Actually, I am getting colors as a string like "#FF00FF". I want them to set as BackColor to the imagebuttons at runtime. I have tried...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
0
by: dengel | last post by:
I'm a classic ASP/VbScript user, transitioning to c# and .NET. I'm making a little PW change utility which does this: 1. User inputs an email address/username (into a textbox) 2. User inputs...
3
by: Peter | last post by:
I have a datalist and I want the datalist to grow from no records to fill the screen, but not go beyond the screen height. How do I do that? I've implemented the scroll bars but it works only for...
2
tjc0ol
by: tjc0ol | last post by:
Hi guys, Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.