472,351 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

Set row color of a datagrid when more than one datagrid on a form

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 datagrida. I would like to set it so that

if value of column 3 in datagrid 1 is < 100 set to red, if = 100 set to green
if value of column 3 in datagrid 2 is < 90 set to red, if >= 90 set to green
if value of column 3 in datagrid 3is < 80 set to red, if >= 80set to green

No matter how I write my code I cannot seem to get the coloring to apply to
just one datagrid

My code is below:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<script runat="server">

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Decimal.Parse(e.Row.Cells[3].Text) < 100)
e.Row.Cells[3].BackColor = Color.IndianRed;
else
e.Row.Cells[3].BackColor = Color.MediumSeaGreen;
}
}
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Decimal.Parse(e.Row.Cells[3].Text) < 70)
e.Row.Cells[3].BackColor = Color.IndianRed;
else
e.Row.Cells[3].BackColor = Color.MediumSeaGreen;
}

}
protected void Page_Load(object sender, EventArgs e)
{

}

protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{

}

</script>

<html><!-- InstanceBegin template="/Templates/supportstats.dwt"
codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>HKS Medical Information Systems</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet" type="text/css" href="styles.css">
<script language="JavaScript" src="common.js" type="text/JavaScript"></script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --><!--
InstanceParam name="NavAboutUsON" type="boolean" value="false" --><!--
InstanceParam name="NavSoftwareSolutionsON" type="boolean" value="false"
--><!-- InstanceParam name="NavServicesON" type="boolean" value="false"
--><!-- InstanceParam name="NavSupportON" type="boolean" value="false"
--><!-- InstanceParam name="NavNewsON" type="boolean" value="false" --><!--
InstanceParam name="NavContactON" type="boolean" value="false" -->
<script language="JavaScript">
function breadCrumbs(base,delStr,defp,cStyle,tStyle,dStyle, nl) { // by Paul
Davis - http://www.kaosweaver.com
loc=window.location.toString();subs=loc.substr(loc .indexOf(base)+base.length+1).split("/");
document.write('<a href="'+getLoc(subs.length-1)+defp+'"
class="'+cStyle+'">Home</a '+'<span class="'+dStyle+'">'+delStr+'</span');
a=(loc.indexOf(defp)==-1)?1:2;for (i=0;i<(subs.length-a);i++) {
subs[i]=makeCaps(unescape(subs[i]));
document.write('<a href="'+getLoc(subs.length-i-2)+defp+'"
class="'+cStyle+'">'+subs[i]+'</a '+'<span
class="'+dStyle+'">'+delStr+'</span');}
if (nl==1) document.write("<br>");document.write('<span
class="'+tStyle+'">'+document.title+'</span>');
}
function makeCaps(a) {
g=a.split(' ');for (l=0;l<g.length;l++)
g[l]=g[l].toUpperCase().slice(0,1)+g[l].slice(1);
return g.join(" ");
}
function getLoc(c) {
var d="";if (c>0) for (k=0;k<c;k++) d=d+"../"; return d;
}
</script>
</head>

<body link="#6F96C6" alink="#6F96C6" vlink="#6F96C6">

<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="224"><a href="http://www.hksys.com"><img
src="images/hdr_logo.gif" alt="HKS Medical Information Systems" width="187"
height="79" border="0"></a></td>
<td width="776"><!-- InstanceBeginEditable name="Header" --><img
src="images/hdr_home.jpg" alt="" height="79" style="width: 811px"><!--
InstanceEndEditable --></td>
</tr>
</table>
<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" bgcolor="#6F96C6"</td>
<td height="25" align="RIGHT" bgcolor="#6F96C6"><table width="990"
height="23" border="0" cellpadding="0" cellspacing="0">
<form action="search/search.pl" method="GET" name="SearchSite">
<input type="hidden" name="p" value="1" /><input type="hidden"
name="lang" value="en" /><input type="hidden" name="include" value=""
/><input type="hidden" name="exclude" value="" /><input type="hidden"
name="penalty" value="0" /><input type="HIDDEN" name="mode" value="any">

</form>
</table></td>
</tr>
<tr>
<td height="8" colspan="2"><img src="images/spacer.gif" width="1"
height="8"></td>
</tr>
</table>
<table width="996" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="1000" valign="TOP"><table width="1000" border="0"
cellpadding="0" cellspacing="0" bgcolor="#A4A4A5">
<tr>
<td height="1" colspan="3"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
<tr>

<td width="1000" bgcolor="#FFFFFF"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td width="100%" bgcolor="#6F96C6"><!-- InstanceBeginEditable
name="PageTitle" --><span class="pageTitle">Support SLA
Compliance </span><!-- InstanceEndEditable --></td>
</tr>
<tr>
<td><table width="1000" border="0" cellpadding="0"
cellspacing="0">
<tr>

<td width="1000"><!-- InstanceBeginEditable
name="PageContent" -->
<form id="form1" runat="server">
<div>
<h1>
HKS Support Statistics</h1>
<p>
Click Links for more detail,
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/priority1-main.aspx">Priority 1 </asp:HyperLink>
Issues Last Updated:</span>
</p>
<p>
<asp:HyperLink ID="HyperLink4" runat="server"
NavigateUrl="~/priority1-graph.aspx"
Target="_blank">Graph</asp:HyperLink</p>
<p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
Number_of_tickets_opened, Number_of_tickets_closed_within_24hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority1 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority1 AS Priority1_1))

"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource1" Font-Names="Arial"
ForeColor="#333333" GridLines="None"
OnSelectedIndexChanged="GridView1_SelectedIndexCha nged" >
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField DataField="Number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="Number_of_tickets_opened" />
<asp:BoundField
DataField="Number_of_tickets_closed_within_24hrs" HeaderText="# of Issues
Resolved Within 24hrs"

SortExpression="Number_of_tickets_closed_within_24 hrs" />
<asp:BoundField DataField="% of Tickets Closed within
SLAS" HeaderText="% of Issues Resolved Within SLAs"
SortExpression="% of Tickets Closed within SLAS" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/priority2-main.aspx">Priority 2</asp:HyperLinkIssues Last
Updated:</span></p>
<p>
<span style="font-family: Arial"<asp:HyperLink ID="HyperLink5"
runat="server" NavigateUrl="~/priority2-graph.aspx"
Target="_blank">Graph</asp:HyperLink>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
Number_of_tickets_opened, Number_of_tickets_closed_within_48hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority2 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority2 AS Priority2_1))
"></asp:SqlDataSource>
<asp:GridView ID="GridView2" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource2" ForeColor="#333333"
GridLines="None" OnSelectedIndexChanged="GridView2_SelectedIndexCha nged">
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField DataField="Number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="Number_of_tickets_opened" />
<asp:BoundField
DataField="Number_of_tickets_closed_within_48hrs" HeaderText="# of Issues
Resolved Within 48hrs"

SortExpression="Number_of_tickets_closed_within_48 hrs" />
<asp:BoundField DataField="% of Tickets Closed
within SLAS" HeaderText="% of Issues Resolved Within SLAS"
SortExpression="% of Tickets Closed within SLAS"
/>
</Columns>
</asp:GridView>
</span>
</p>
<p>
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="~/priority3-main.aspx">Priority 3</asp:HyperLink>
Issues Last Updated:</span></p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink6" runat="server"
NavigateUrl="~/priority3-graph.aspx"
Target="_blank">Graph</asp:HyperLink></span</p>
<p>
<span style="font-family: Arial">
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
number_of_tickets_opened, number_of_tickets_closed_within_120hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority3 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority3 AS Priority3_1))"></asp:SqlDataSource>
<asp:GridView ID="GridView3" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource3" ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField DataField="number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="number_of_tickets_opened" />
<asp:BoundField
DataField="number_of_tickets_closed_within_120hrs" HeaderText="# of Issues
Resolved Within 200hrs"

SortExpression="number_of_tickets_closed_within_12 0hrs" />
<asp:BoundField DataField="% of Tickets Closed
within SLAS" HeaderText="% of Issues Resolved Within SLAs"
SortExpression="% of Tickets Closed within SLAS"
/>
</Columns>
</asp:GridView>
</span>
</p>

</div>
</form>
<!-- InstanceEndEditable --></td>

</tr>
</table></td>
</tr>
</table></td>
<td width="1"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
<tr>
<td height="1" colspan="3"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
</table></td>
</tr>
</table>
<table width="1000" border="0" cellpadding="8" cellspacing="0">
<tr>
<td width="1000" align="CENTER" class="footer">© 2006 HKS Medical
Information
Systems | <a href="http://web1.hksys.com/sw/" target="_blank"
class="footerLink">User
Support</a| <a href="http://www.hksys.com/admin/" target="_blank"
class="footerLink">Client
Login</a| <a href="default.htm" class="footerLink">Home</a></td>
</tr>
<tr>
<td bgcolor="#6F96C6"><img src="images/spacer.gif" width="1" height="10"
alt=""></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>

Sep 26 '06 #1
2 3311
Mike,

Have you considered creating a subclass of the data grid and exposing a
property which has the threshold for the value in column three? It might
make things a little easier for you.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike Baugh" <Mi*******@discussions.microsoft.comwrote in message
news:3D**********************************@microsof t.com...
>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 datagrida. I would like to set it so that

if value of column 3 in datagrid 1 is < 100 set to red, if = 100 set to
green
if value of column 3 in datagrid 2 is < 90 set to red, if >= 90 set to
green
if value of column 3 in datagrid 3is < 80 set to red, if >= 80set to green

No matter how I write my code I cannot seem to get the coloring to apply
to
just one datagrid

My code is below:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<script runat="server">

protected void GridView1_SelectedIndexChanged(object sender, EventArgs
e)
{

}

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Decimal.Parse(e.Row.Cells[3].Text) < 100)
e.Row.Cells[3].BackColor = Color.IndianRed;
else
e.Row.Cells[3].BackColor = Color.MediumSeaGreen;
}
}
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Decimal.Parse(e.Row.Cells[3].Text) < 70)
e.Row.Cells[3].BackColor = Color.IndianRed;
else
e.Row.Cells[3].BackColor = Color.MediumSeaGreen;
}

}
protected void Page_Load(object sender, EventArgs e)
{

}

protected void GridView2_SelectedIndexChanged(object sender, EventArgs
e)
{

}

</script>

<html><!-- InstanceBegin template="/Templates/supportstats.dwt"
codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>HKS Medical Information Systems</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet" type="text/css" href="styles.css">
<script language="JavaScript" src="common.js"
type="text/JavaScript"></script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --><!--
InstanceParam name="NavAboutUsON" type="boolean" value="false" --><!--
InstanceParam name="NavSoftwareSolutionsON" type="boolean" value="false"
--><!-- InstanceParam name="NavServicesON" type="boolean" value="false"
--><!-- InstanceParam name="NavSupportON" type="boolean" value="false"
--><!-- InstanceParam name="NavNewsON" type="boolean"
value="false" --><!--
InstanceParam name="NavContactON" type="boolean" value="false" -->
<script language="JavaScript">
function breadCrumbs(base,delStr,defp,cStyle,tStyle,dStyle, nl) { // by
Paul
Davis - http://www.kaosweaver.com
loc=window.location.toString();subs=loc.substr(loc .indexOf(base)+base.length+1).split("/");
document.write('<a href="'+getLoc(subs.length-1)+defp+'"
class="'+cStyle+'">Home</a '+'<span class="'+dStyle+'">'+delStr+'</span>
');
a=(loc.indexOf(defp)==-1)?1:2;for (i=0;i<(subs.length-a);i++) {
subs[i]=makeCaps(unescape(subs[i]));
document.write('<a href="'+getLoc(subs.length-i-2)+defp+'"
class="'+cStyle+'">'+subs[i]+'</a '+'<span
class="'+dStyle+'">'+delStr+'</span');}
if (nl==1) document.write("<br>");document.write('<span
class="'+tStyle+'">'+document.title+'</span>');
}
function makeCaps(a) {
g=a.split(' ');for (l=0;l<g.length;l++)
g[l]=g[l].toUpperCase().slice(0,1)+g[l].slice(1);
return g.join(" ");
}
function getLoc(c) {
var d="";if (c>0) for (k=0;k<c;k++) d=d+"../"; return d;
}
</script>
</head>

<body link="#6F96C6" alink="#6F96C6" vlink="#6F96C6">

<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="224"><a href="http://www.hksys.com"><img
src="images/hdr_logo.gif" alt="HKS Medical Information Systems"
width="187"
height="79" border="0"></a></td>
<td width="776"><!-- InstanceBeginEditable name="Header" --><img
src="images/hdr_home.jpg" alt="" height="79" style="width: 811px"><!--
InstanceEndEditable --></td>
</tr>
</table>
<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" bgcolor="#6F96C6"</td>
<td height="25" align="RIGHT" bgcolor="#6F96C6"><table width="990"
height="23" border="0" cellpadding="0" cellspacing="0">
<form action="search/search.pl" method="GET" name="SearchSite">
<input type="hidden" name="p" value="1" /><input type="hidden"
name="lang" value="en" /><input type="hidden" name="include" value=""
/><input type="hidden" name="exclude" value="" /><input type="hidden"
name="penalty" value="0" /><input type="HIDDEN" name="mode" value="any">

</form>
</table></td>
</tr>
<tr>
<td height="8" colspan="2"><img src="images/spacer.gif" width="1"
height="8"></td>
</tr>
</table>
<table width="996" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="1000" valign="TOP"><table width="1000" border="0"
cellpadding="0" cellspacing="0" bgcolor="#A4A4A5">
<tr>
<td height="1" colspan="3"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
<tr>

<td width="1000" bgcolor="#FFFFFF"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td width="100%" bgcolor="#6F96C6"><!-- InstanceBeginEditable
name="PageTitle" --><span class="pageTitle">Support SLA
Compliance </span><!-- InstanceEndEditable --></td>
</tr>
<tr>
<td><table width="1000" border="0" cellpadding="0"
cellspacing="0">
<tr>

<td width="1000"><!-- InstanceBeginEditable
name="PageContent" -->
<form id="form1" runat="server">
<div>
<h1>
HKS Support Statistics</h1>
<p>
Click Links for more detail,
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/priority1-main.aspx">Priority 1 </asp:HyperLink>
Issues Last Updated:</span>
</p>
<p>
<asp:HyperLink ID="HyperLink4" runat="server"
NavigateUrl="~/priority1-graph.aspx"
Target="_blank">Graph</asp:HyperLink</p>
<p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
Number_of_tickets_opened, Number_of_tickets_closed_within_24hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority1 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority1 AS Priority1_1))

"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource1" Font-Names="Arial"
ForeColor="#333333" GridLines="None"
OnSelectedIndexChanged="GridView1_SelectedIndexCha nged" >
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField DataField="Number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="Number_of_tickets_opened" />
<asp:BoundField
DataField="Number_of_tickets_closed_within_24hrs" HeaderText="# of Issues
Resolved Within 24hrs"

SortExpression="Number_of_tickets_closed_within_24 hrs" />
<asp:BoundField DataField="% of Tickets Closed within
SLAS" HeaderText="% of Issues Resolved Within SLAs"
SortExpression="% of Tickets Closed within SLAS" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/priority2-main.aspx">Priority 2</asp:HyperLinkIssues Last
Updated:</span></p>
<p>
<span style="font-family: Arial"<asp:HyperLink
ID="HyperLink5"
runat="server" NavigateUrl="~/priority2-graph.aspx"
Target="_blank">Graph</asp:HyperLink>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
Number_of_tickets_opened, Number_of_tickets_closed_within_48hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority2 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority2 AS Priority2_1))
"></asp:SqlDataSource>
<asp:GridView ID="GridView2" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource2" ForeColor="#333333"
GridLines="None" OnSelectedIndexChanged="GridView2_SelectedIndexCha nged">
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField
DataField="Number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="Number_of_tickets_opened" />
<asp:BoundField
DataField="Number_of_tickets_closed_within_48hrs" HeaderText="# of Issues
Resolved Within 48hrs"

SortExpression="Number_of_tickets_closed_within_48 hrs" />
<asp:BoundField DataField="% of Tickets Closed
within SLAS" HeaderText="% of Issues Resolved Within SLAS"
SortExpression="% of Tickets Closed within
SLAS"
/>
</Columns>
</asp:GridView>
</span>
</p>
<p>
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="~/priority3-main.aspx">Priority 3</asp:HyperLink>
Issues Last Updated:</span></p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink6" runat="server"
NavigateUrl="~/priority3-graph.aspx"
Target="_blank">Graph</asp:HyperLink></span</p>
<p>
<span style="font-family: Arial">
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
number_of_tickets_opened, number_of_tickets_closed_within_120hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority3 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority3 AS Priority3_1))"></asp:SqlDataSource>
<asp:GridView ID="GridView3" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource3" ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField
DataField="number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="number_of_tickets_opened" />
<asp:BoundField
DataField="number_of_tickets_closed_within_120hrs" HeaderText="# of Issues
Resolved Within 200hrs"

SortExpression="number_of_tickets_closed_within_12 0hrs" />
<asp:BoundField DataField="% of Tickets Closed
within SLAS" HeaderText="% of Issues Resolved Within SLAs"
SortExpression="% of Tickets Closed within
SLAS"
/>
</Columns>
</asp:GridView>
</span>
</p>

</div>
</form>
<!-- InstanceEndEditable --></td>

</tr>
</table></td>
</tr>
</table></td>
<td width="1"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
<tr>
<td height="1" colspan="3"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
</table></td>
</tr>
</table>
<table width="1000" border="0" cellpadding="8" cellspacing="0">
<tr>
<td width="1000" align="CENTER" class="footer">© 2006 HKS Medical
Information
Systems | <a href="http://web1.hksys.com/sw/" target="_blank"
class="footerLink">User
Support</a| <a href="http://www.hksys.com/admin/" target="_blank"
class="footerLink">Client
Login</a| <a href="default.htm" class="footerLink">Home</a></td>
</tr>
<tr>
<td bgcolor="#6F96C6"><img src="images/spacer.gif" width="1" height="10"
alt=""></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>

Sep 26 '06 #2
many thanks for the quick reply. It is greatly appreciated

Excuse me for being naive but I am new to c# so am not sure how to create a
subclass.

Do you have any code snippets that I might be able to modify?

many thanks

Mike

"Nicholas Paldino [.NET/C# MVP]" wrote:
Mike,

Have you considered creating a subclass of the data grid and exposing a
property which has the threshold for the value in column three? It might
make things a little easier for you.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike Baugh" <Mi*******@discussions.microsoft.comwrote in message
news:3D**********************************@microsof t.com...
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 datagrida. I would like to set it so that

if value of column 3 in datagrid 1 is < 100 set to red, if = 100 set to
green
if value of column 3 in datagrid 2 is < 90 set to red, if >= 90 set to
green
if value of column 3 in datagrid 3is < 80 set to red, if >= 80set to green

No matter how I write my code I cannot seem to get the coloring to apply
to
just one datagrid

My code is below:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<script runat="server">

protected void GridView1_SelectedIndexChanged(object sender, EventArgs
e)
{

}

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Decimal.Parse(e.Row.Cells[3].Text) < 100)
e.Row.Cells[3].BackColor = Color.IndianRed;
else
e.Row.Cells[3].BackColor = Color.MediumSeaGreen;
}
}
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Decimal.Parse(e.Row.Cells[3].Text) < 70)
e.Row.Cells[3].BackColor = Color.IndianRed;
else
e.Row.Cells[3].BackColor = Color.MediumSeaGreen;
}

}
protected void Page_Load(object sender, EventArgs e)
{

}

protected void GridView2_SelectedIndexChanged(object sender, EventArgs
e)
{

}

</script>

<html><!-- InstanceBegin template="/Templates/supportstats.dwt"
codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>HKS Medical Information Systems</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet" type="text/css" href="styles.css">
<script language="JavaScript" src="common.js"
type="text/JavaScript"></script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --><!--
InstanceParam name="NavAboutUsON" type="boolean" value="false" --><!--
InstanceParam name="NavSoftwareSolutionsON" type="boolean" value="false"
--><!-- InstanceParam name="NavServicesON" type="boolean" value="false"
--><!-- InstanceParam name="NavSupportON" type="boolean" value="false"
--><!-- InstanceParam name="NavNewsON" type="boolean"
value="false" --><!--
InstanceParam name="NavContactON" type="boolean" value="false" -->
<script language="JavaScript">
function breadCrumbs(base,delStr,defp,cStyle,tStyle,dStyle, nl) { // by
Paul
Davis - http://www.kaosweaver.com
loc=window.location.toString();subs=loc.substr(loc .indexOf(base)+base.length+1).split("/");
document.write('<a href="'+getLoc(subs.length-1)+defp+'"
class="'+cStyle+'">Home</a '+'<span class="'+dStyle+'">'+delStr+'</span>
');
a=(loc.indexOf(defp)==-1)?1:2;for (i=0;i<(subs.length-a);i++) {
subs[i]=makeCaps(unescape(subs[i]));
document.write('<a href="'+getLoc(subs.length-i-2)+defp+'"
class="'+cStyle+'">'+subs[i]+'</a '+'<span
class="'+dStyle+'">'+delStr+'</span');}
if (nl==1) document.write("<br>");document.write('<span
class="'+tStyle+'">'+document.title+'</span>');
}
function makeCaps(a) {
g=a.split(' ');for (l=0;l<g.length;l++)
g[l]=g[l].toUpperCase().slice(0,1)+g[l].slice(1);
return g.join(" ");
}
function getLoc(c) {
var d="";if (c>0) for (k=0;k<c;k++) d=d+"../"; return d;
}
</script>
</head>

<body link="#6F96C6" alink="#6F96C6" vlink="#6F96C6">

<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="224"><a href="http://www.hksys.com"><img
src="images/hdr_logo.gif" alt="HKS Medical Information Systems"
width="187"
height="79" border="0"></a></td>
<td width="776"><!-- InstanceBeginEditable name="Header" --><img
src="images/hdr_home.jpg" alt="" height="79" style="width: 811px"><!--
InstanceEndEditable --></td>
</tr>
</table>
<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" bgcolor="#6F96C6"</td>
<td height="25" align="RIGHT" bgcolor="#6F96C6"><table width="990"
height="23" border="0" cellpadding="0" cellspacing="0">
<form action="search/search.pl" method="GET" name="SearchSite">
<input type="hidden" name="p" value="1" /><input type="hidden"
name="lang" value="en" /><input type="hidden" name="include" value=""
/><input type="hidden" name="exclude" value="" /><input type="hidden"
name="penalty" value="0" /><input type="HIDDEN" name="mode" value="any">

</form>
</table></td>
</tr>
<tr>
<td height="8" colspan="2"><img src="images/spacer.gif" width="1"
height="8"></td>
</tr>
</table>
<table width="996" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="1000" valign="TOP"><table width="1000" border="0"
cellpadding="0" cellspacing="0" bgcolor="#A4A4A5">
<tr>
<td height="1" colspan="3"><img src="images/spacer.gif" width="1"
height="1"></td>
</tr>
<tr>

<td width="1000" bgcolor="#FFFFFF"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td width="100%" bgcolor="#6F96C6"><!-- InstanceBeginEditable
name="PageTitle" --><span class="pageTitle">Support SLA
Compliance </span><!-- InstanceEndEditable --></td>
</tr>
<tr>
<td><table width="1000" border="0" cellpadding="0"
cellspacing="0">
<tr>

<td width="1000"><!-- InstanceBeginEditable
name="PageContent" -->
<form id="form1" runat="server">
<div>
<h1>
HKS Support Statistics</h1>
<p>
Click Links for more detail,
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/priority1-main.aspx">Priority 1 </asp:HyperLink>
Issues Last Updated:</span>
</p>
<p>
<asp:HyperLink ID="HyperLink4" runat="server"
NavigateUrl="~/priority1-graph.aspx"
Target="_blank">Graph</asp:HyperLink</p>
<p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
Number_of_tickets_opened, Number_of_tickets_closed_within_24hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority1 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority1 AS Priority1_1))

"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource1" Font-Names="Arial"
ForeColor="#333333" GridLines="None"
OnSelectedIndexChanged="GridView1_SelectedIndexCha nged" >
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField DataField="Number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="Number_of_tickets_opened" />
<asp:BoundField
DataField="Number_of_tickets_closed_within_24hrs" HeaderText="# of Issues
Resolved Within 24hrs"

SortExpression="Number_of_tickets_closed_within_24 hrs" />
<asp:BoundField DataField="% of Tickets Closed within
SLAS" HeaderText="% of Issues Resolved Within SLAs"
SortExpression="% of Tickets Closed within SLAS" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
<span style="font-family: Arial">
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/priority2-main.aspx">Priority 2</asp:HyperLinkIssues Last
Updated:</span></p>
<p>
<span style="font-family: Arial"<asp:HyperLink
ID="HyperLink5"
runat="server" NavigateUrl="~/priority2-graph.aspx"
Target="_blank">Graph</asp:HyperLink>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:SupportStatsConnectionString %>"
SelectCommand="SELECT Priority, Date,
Number_of_tickets_opened, Number_of_tickets_closed_within_48hrs,
ROUND([%_of_tickets_closed_within_slas], 0) AS '% of Tickets Closed within
SLAS' FROM dbo.Priority2 WHERE (Date IN (SELECT MAX(Date) AS date FROM
dbo.Priority2 AS Priority2_1))
"></asp:SqlDataSource>
<asp:GridView ID="GridView2" runat="server"
OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False"
CellPadding="4"
DataSourceID="SqlDataSource2" ForeColor="#333333"
GridLines="None" OnSelectedIndexChanged="GridView2_SelectedIndexCha nged">
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" HorizontalAlign="Center"
Font-Bold="True" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Date" HeaderText="Date"
ReadOnly="True" SortExpression="Date" />
<asp:BoundField
DataField="Number_of_tickets_opened"
HeaderText="# of Issues Opened"
SortExpression="Number_of_tickets_opened" />
<asp:BoundField
DataField="Number_of_tickets_closed_within_48hrs" HeaderText="# of Issues
Resolved Within 48hrs"

SortExpression="Number_of_tickets_closed_within_48 hrs" />
<asp:BoundField DataField="% of Tickets Closed
within SLAS" HeaderText="% of Issues Resolved Within SLAS"
Sep 26 '06 #3

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

Similar topics

0
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with...
1
by: Joe Bloggs | last post by:
I am trying display the contents of a table in a web page, select certain rows from that table and then display the fields that I have selected...
0
by: mgenti | last post by:
I am experiencing a problem when I add a row to a DataTable that is used on a DataGrid in my Windows Form application. When I add a new row I no...
1
by: Stephen J. Shephard | last post by:
Hi there, I know this is probably a 101-type question, and I've dealt with it using client script blocks before, but I'm curious about what the...
4
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes...
0
by: Marcus Kwok | last post by:
I am having a weird problem with my DataGrid that is bound to an ArrayList. My situation is as follows: I have two DataGrids on a modal form. ...
9
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro,...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using...
8
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.