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

datagrid template column forecolor

This template column should show forecolor as red when the bit
datafield 'SIG' is true.
<asp:TemplateColumn HeaderText="Area">
<ItemStyle HorizontalAlign="left"></ItemStyle>
<ItemTemplate>
<asp:HyperLink runat="server" ForeColor='<%#
IIf(DataBinder.Eval(Container.DataItem, "SIG"), "red","black") %>'
Text='<%# DataBinder.Eval(Container, "DataItem.AREA_NAME") %>'
ID="Hyperlink1">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>

I've checked the data - no nulls, error msg is : specified cast is not
valid. Definately the forecolor since if I remove it it runs fine.
Thanks for all help !

Oct 6 '07 #1
3 3100
You are limited in data binding expressions. You can bind to any public
field or property on the containing page or on the server control's
immediate naming container available as Container.DataItem. IIf statement is
neither of them.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"dodgeyb" <ch***@ctlsoft.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
This template column should show forecolor as red when the bit
datafield 'SIG' is true.
<asp:TemplateColumn HeaderText="Area">
<ItemStyle HorizontalAlign="left"></ItemStyle>
<ItemTemplate>
<asp:HyperLink runat="server" ForeColor='<%#
IIf(DataBinder.Eval(Container.DataItem, "SIG"), "red","black") %>'
Text='<%# DataBinder.Eval(Container, "DataItem.AREA_NAME") %>'
ID="Hyperlink1">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>

I've checked the data - no nulls, error msg is : specified cast is not
valid. Definately the forecolor since if I remove it it runs fine.
Thanks for all help !

Oct 7 '07 #2
I'm always using the iif function in datagrid template cols ?!, and
this is the first prob I've encoutered. How do you do conditional
formatting ?
Thanks & regards
Chris

Oct 7 '07 #3
Ok, I am not good with VB.

What is the type of the "SIG" field? Apparently, IIf expects the first
parameter to be boolean and DataBinder.Eval(Container.DataItem, "SIG")
doesn't not evaluate to a boolean.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"dodgeyb" <ch***@ctlsoft.comwrote in message
news:11**********************@y42g2000hsy.googlegr oups.com...
I'm always using the iif function in datagrid template cols ?!, and
this is the first prob I've encoutered. How do you do conditional
formatting ?
Thanks & regards
Chris

Oct 8 '07 #4

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
1
by: SamIAm | last post by:
Hi I have a DataGrid called dgTraders 1 of the columns is a template column and this column has a Dropdown box in its HeaderTemplate section. The Dropdown box is called selCities. How do I...
2
by: Bob Trabucco | last post by:
Hello all, I have a Datagrid on a page. 1 column is a template column with a checkbox (unbound). The rest of the columns are databound that are added programatically. If in the Page_Load I...
1
by: Bob Trabucco | last post by:
Hello all, I have a Datagrid on a page. 1 column is a template column with a checkbox (unbound). The rest of the columns are databound that are added programatically. Grid Definition... ...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
1
by: jeguillo | last post by:
I am trying to retrieve the text within each cell in a datagrid in order to change the color of each cell, depending on the value within that cell. This works fine on the cells that are bound...
2
by: ismaelf | last post by:
i have a textbox in a template column in a datagrid, it displays the initial value of the row, but when i change it remains with the original value (it doesnt get the new value..) i fill the...
6
by: Scott McDaniel | last post by:
I'm using Visual Studio 2005 with the .NET 2.0.50727 framework, and we're using the standard Datagrid control bound to a SQL Server. We have two groups of users - "full edit" users, and "view...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
7
by: Mark B | last post by:
Can someone write some VB.Net example code for me that does this: 1) Creates a gridview control with the results of a SQL stored procedure that has 1 parameter (text) 2) Adds an extra column...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.