Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

Cannot dynamically assign a BackColor to a datalist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
.Net Sports - 16 Apr 2008 21:32 GMT
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
Mark Fitzpatrick - 17 Apr 2008 01:39 GMT
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

>I need to dynamically assign a datalist attribute upon a helper
> function receiving data from a querystring. If a user picks a certain
[quoted text clipped - 6 lines]
> BackColor=') does not match any properties within a
> 'System.Web.UI.WebControls.DataList', make sure it is well-formed
.Net Sports - 17 Apr 2008 18:06 GMT
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.QueryString("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

> Do it programatically. You can access the property directly from code as
> follows:
[quoted text clipped - 16 lines]
> > BackColor=') does not match any properties within a
> > 'System.Web.UI.WebControls.DataList', make sure it is well-formed
wisccal@googlemail.com - 18 Apr 2008 12:07 GMT
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

> Thanks for your response. There is no code behind in these scripts/
> programs I am using. Inside the Datalist form block, I have:
[quoted text clipped - 43 lines]
> > > BackColor=') does not match any properties within a
> > > 'System.Web.UI.WebControls.DataList', make sure it is well-formed
wisccal@googlemail.com - 18 Apr 2008 12:07 GMT
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

> Thanks for your response. There is no code behind in these scripts/
> programs I am using. Inside the Datalist form block, I have:
[quoted text clipped - 43 lines]
> > > BackColor=') does not match any properties within a
> > > 'System.Web.UI.WebControls.DataList', make sure it is well-formed

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.