473,739 Members | 6,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting BackColor of GridView cell dynamically

I have a number of colours in a database linked to different conditions,
and this data is displayed in a gridview. I want to set the BackColor
of a gridview cell dependent upon this value, for example FF0000 etc.
The code I have used gives me the error 'specified cast is not valid' :

<asp:TemplateFi eld HeaderText="For ecast Type"
SortExpression= "ForecastDescri ption">
<ItemTemplate >
<asp:Label
ID="lblForecast Type" Text='<%# Eval("ForecastD escription") %>'
BackColor='<%# Eval("ForecastC olor") %>' runat="server"> </asp:Label>
</ItemTemplate>
<ItemStyle Height="24px"
Width="50px" />
</asp:TemplateFie ld>

Any ideas how to do this?

*** Sent via Developersdex http://www.developersdex.com ***
May 30 '06 #1
0 1759

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

Similar topics

3
2177
by: Rob Meade | last post by:
Hi all, I need to set some table cells which I am adding from code. I am using; cell.backcolor = cell.backcolor.white for example to set it to white - this is all very well and good for a 'named' colour - but how do I set this for #d4c5db as an example? I have
0
1116
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 to get the Xml values in a DataTable and bind them in the HTML to the ImageButtons as BackColor = '<%# DataBinder.Eval(Container.DataListItem,"Color") %>' It is giving error. I suppose that is due to the portion "#". How can I implement this?
1
2543
by: NH | last post by:
ANy ideas on how to acheive this? I want to display a dynamically created image when a mouse over occurs on a gridview event. I need some way of creating the image (it will be a small chart type image) on each rowdatabound event and then display it on a mouse over on the gridview cell. Is it possible?
4
8331
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the date column always shows the date and time while I just want the short date. I have tried applying a format string {0:d} but to no avail. I saw a lot of posts regarding the htmlencode property but I do not know how to turn that off for a...
8
9151
by: Jeff | last post by:
ASP.NET 2.0 I have a webpage which contains a GridView. I want this GridView's HeaderTemplate to display the text "Inbox" or "Outbox"... So I think I need to set the value in the code behind file... Anyone got any tips about how to do this? Jeff
1
15046
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have to add controls dynamically as I am trying to write a reusable , general , spreadsheet like display control that can take advantage of the built- in update and delete features of the SqlDataSource/Gridview controls. This user control can get its...
5
2983
by: davidson1 | last post by:
Hai Friends, I have the following code for Dynamically Created Tables, I have created the panel in the webform....... Dim tab5 As New Table Dim row1 As New TableRow Dim cell1 As New TableCell cell1.Text = "Java" row1.Cells.Add(cell1)
3
2059
by: giveDsolution | last post by:
Hello Frds, I have bind a gridview with the help of a Datatable as the columns are added dynamically. But my problem is i have to add a gridview in any cell (which will be bind by another Query) which contains the value "0". How to do this,thanxs in advance for Any kind of suggestion .......
1
3341
by: nirmala26 | last post by:
Hi All, I am using C#.net to develop a web application. I have a gridview and a table displaying two different lists of data. I want to have the backcolor of the cell (of both gridview and table) to blink between two colors, say for example the cell background color must blink (two colors using yellow, green). Is this possible ? I am able to only set the backcolor property with just one value. Can anyone help me with some ideas on how...
0
8969
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
8794
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,...
1
9269
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
9211
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8216
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...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2195
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.