Highlighting Gridview Row Based on Column Criteria

i Have the following "Code  Behind" needed to highlight a based on column criteria.   The column with the with the criteria is a template field.   I am getting the following error for the Code Behind.

Compiler Error Message: CS1513: } expected

Source Error:

 

Line 20:         e.Row.BackColor = System.Drawing.Color.Yellow;  
Line 21:    }
Line 22: }  
Line 23:  
Line 24:    
 

Source File: d:\wwwsites\laxpmcom\LAS\Home\Home_Data1.aspx.cs    Line: 22

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Home_data1 : System.Web.UI.Page
{
    
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
	if (e.Row.RowType == DataControlRowType.DataRow)
	
	if (e.Row.RowType == DataControlRowType.DataRow)   
  
    if (e.Row.Cells[8].Text == "AOS" | e.Row.Cells[8].Equals(DBNull.Value))   
   {   
        e.Row.BackColor = System.Drawing.Color.Yellow;   
   }
}   
 
}

Open in new window

BOEING39Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
BOEING39Connect With a Mentor Author Commented:
Also is the "On row Data Bound" Event look correct?
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" onrowdatabound="GridView1_RowDataBound" DataKeyNames="ID" AllowPaging="True" AllowSorting="True" ShowFooter="True" GridLines="None">
					<RowStyle Font-Names="Arial" Font-Size="8pt" Width="1300px" />
					<Columns>
						<asp:commandfield ShowEditButton="True">
							<ItemStyle HorizontalAlign="Left" Wrap="False" Width="40px" />
						</asp:commandfield>
						<asp:boundfield DataField="Ship" HeaderText="Ship" SortExpression="Ship">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="40px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="Sta" SortExpression="Station">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownListSta" Width="82px" Height="22px" SelectedValue='<%# Bind("Station") %>' DataValueField="Station" DataTextField="Station" DataSourceID="AccessDataSource5">
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource5" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Station] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Station") %>' id="Label9">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="70px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="ArrDate" SortExpression="ArrDate">
							<EditItemTemplate>
								<asp:TextBox runat="server" Text='<%# Bind("ArrDate", "{0:MM/dd/yyyy}") %>' id="ArrDate">
								</asp:TextBox>
								<a href="javascript:;" onclick="window.open('popup.aspx?textbox=ArrDate','cal','width=250,height=225,left=270,top=180')">
								<img src="SmallCalendar.gif" border="0" width="16" height="16"></img></a>
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("ArrDate", "{0:MM/dd/yyyy}") %>' id="Label6">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="ArrTime" DataFormatString="{0:hh:mm.FF tt}" HeaderText="ArrTime" SortExpression="ArrTime">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="DepDate" SortExpression="DepDate">
							<EditItemTemplate>
								<asp:TextBox runat="server" Text='<%# Bind("DepDate", "{0:MM/dd/yyyy}") %>' id="DepDate">
								</asp:TextBox>
								<a href="javascript:;" onclick="window.open('popup.aspx?textbox=DepDate','cal','width=250,height=225,left=270,top=180')">
								<img src="SmallCalendar.gif" border="0" width="16" height="16"></img></a>
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("DepDate", "{0:MM/dd/yyyy}") %>' id="Label7">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="DepTime" DataFormatString="{0:MM/dd/yyyy}" HeaderText="DepTime" SortExpression="DepTime">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="Reason" SortExpression="Reason">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownList1" Width="184px" Height="31px" SelectedValue='<%# Bind("Reason") %>' DataValueField="Reason" DataTextField="Reason" DataSourceID="AccessDataSource1">
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Reason] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Reason") %>' id="Label1">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Left" Wrap="False" Width="150px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Workload AOS Description &amp; Work Progession Detail" SortExpression="Workload">
							<EditItemTemplate>
								<asp:TextBox id="tb7" rows="5" TextMode="MultiLine" runat="server" Width="275px" Height="85px" Text='<%# Bind("Workload") %>' />
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Workload") %>' id="Label4">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Left" Width="500px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Parts/Tooling Other Requirements" SortExpression="Parts">
							<EditItemTemplate>
								<asp:TextBox id="tb8" rows="5" TextMode="MultiLine" runat="server" Width="275px" Height="85px" Text='<%# Bind("Parts") %>' />
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Parts") %>' id="Label5">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Left" Width="350px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Updated" SortExpression="Updated">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownList2" DataValueField="Leads" DataTextField="Leads" DataSourceID="AccessDataSource2" Height="31px" Width="184px" SelectedValue='<%# Bind("updated") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource2" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Leads] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Updated") %>' id="Label2">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="150px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Status" SortExpression="Status">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownList3" DataValueField="Status" DataTextField="Status" DataSourceID="AccessDataSource3" SelectedValue='<%# bind("status") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource3" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Status] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Status") %>' id="Label3">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="EtrDate" SortExpression="EtrDate">
							<EditItemTemplate>
								<asp:TextBox runat="server" Text='<%# Bind("EtrDate", "{0:MM/dd/yyyy}") %>' id="EtrDate">
								</asp:TextBox>
								<a href="javascript:;" onclick="window.open('popup.aspx?textbox=ArrDate','cal','width=250,height=225,left=270,top=180')">
								<img src="SmallCalendar.gif" border="0" width="16" height="16"></img></a>
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("EtrDate", "{0:MM/dd/yyyy}") %>' id="Label8">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="ETRTime" DataFormatString="{0:MM/dd/yyyy}" HeaderText="ETR Time" SortExpression="ETRTime">
							<HeaderStyle Wrap="True" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="80px" />
						</asp:boundfield>
					</Columns>
					<FooterStyle BackColor="Navy" Font-Names="Arial" Font-Size="Small" />
					<PagerStyle BackColor="Navy" Font-Names="Arial" ForeColor="White" />
					<HeaderStyle BackColor="Navy" Font-Names="Arial" Font-Size="Small" ForeColor="White" />
					<EditRowStyle Width="1200px" />
					<AlternatingRowStyle BackColor="Blue" ForeColor="White" />
				</asp:GridView>

Open in new window

0
 
amit_gCommented:
The error is due to extra } in line 22. This would be gone if you remove that line or delete }.
0
 
BOEING39Author Commented:
I removed bracket still same error..
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Miguel OzSoftware EngineerCommented:
Try this:
public partial class Home_data1 : System.Web.UI.Page
{
   
      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
         if (e.Row.RowType == DataControlRowType.DataRow)  
                   {
                      if (e.Row.Cells[8].Text == "AOS" || e.Row.Cells[8].Equals(DBNull.Value))  
                     {  
                        e.Row.BackColor = System.Drawing.Color.Yellow;  
                     }
                   }
               }  
 }
0
 
sumeetsuviCommented:
I have used this code to highlight one row having text "AOS",So try this...

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Home_data1 : System.Web.UI.Page
{

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
      if (e.Row.RowType==DataControlRowType.DataRow)
                if (e.Row.Cells[8].Text == "AOS" || e.Row.Cells[8].Equals(DBNull.Value))  
                {  
                    e.Row.BackColor = System.Drawing.Color.Yellow;  
                }
 }

}
0
 
BOEING39Author Commented:
Tried above getting the following meesage:

(I have attached code files.....

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

 

Line 4:  using System.Web.UI;
Line 5:  using System.Web.UI.WebControls;
Line 6:  public partial class Home_data1 : System.Web.UI.Page
Line 7:  {
Line 8:  
 

Source File: d:\wwwsites\laxpmcom\LAS\Home\Home_Data1.aspx.cs    Line: 6




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home_data1.aspx.cs" Inherits="home_data1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<META HTTP-EQUIV="refresh" CONTENT="1000">  
<head runat="server">

<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
.style1 {
	border-color: #c0c0c0;
	border-width: 0;
	background-color: #ffffff;
}
.style2 {
	font-size: large;
	text-align: center;
	color: #000080;
}
.style10 {
	text-align: left;
}
.style11 {
	color: #FF0000;
}
.style12 {
	text-align: center;
}
.style13 {
	font-size: small;
	font-family: Arial;
}
.style15 {
	background-color: #ffffff;
	border-left-color: #c0c0c0;
	border-left-width: 0px;
	border-right-color: #c0c0c0;
	border-right-width: 0px;
	border-top-color: #c0c0c0;
	border-top-width: 0px;
	border-bottom-color: #c0c0c0;
	border-bottom-width: 0;
}
.style16 {
	border-top-style: solid;
	border-top-width: 1px;
}
.style17 {
	font-size: large;
	text-align: left;
	color: #000080;
}
.style18 {
	font-size: small;
	color: #FF0000;
	font-family: Arial;
}
.style19 {
	font-size: large;
	text-align: center;
	color: #000080;
	font-family: Arial;
}
.style20 {
	font-size: small;
	text-align: center;
	color: #FF0000;
	font-family: Arial;
	text-decoration: underline;
}
.style21 {
	font-size: small;
	text-align: center;
	color: #000080;
	font-family: Arial;
}
</style>
</head>

<body>

<form id="form1" runat="server">
	<table style="width: 1100px" cellpadding="0" cellspacing="0" class="style1" align="center">
		<tr>
			<td class="style19"><strong>LAS Critical Workload and AOS Activity 
			Planner&nbsp;&nbsp; </strong></td>
		</tr>
		<tr>
			<td class="style21" style="height: 20px">(Reference Only Document 
			See GMM For Details)</td>
		</tr>
		<tr>
			<td class="style17" style="height: 48px">
		<span class="style11"><strong><span class="style13">Note:&nbsp; All LAS future and current 
		workload exceptions or off scheduled maintenance events must be listed 
		in this table.</span></strong><em><span class="style13">&nbsp;&nbsp; 
			</span> </em></span><span class="style13">This would include 
		but not limited to AOS aircraft, future work such as Scheduled Engine Changes, &quot;Road Trips&quot; 
		and &quot;specialized work&quot;.&nbsp;  
		Ensure the information listed is accurate and up to date and include 
		specific part numbers, specialized tooling and personnel such as 
		inspection requirements.&nbsp; Information listed must be updated daily 
		by each shift.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></td>
		</tr>
		<tr>
			<td class="style17">
		&nbsp;</td>
		</tr>
		<tr>
			<td class="style20">
		<strong>** Note:&nbsp; Prior to closing any item - Ensure corrective 
		action is properly documented under work progress.&nbsp; **</strong></td>
		</tr>
		<tr>
			<td class="style2" style="height: 20px"></td>
		</tr>
		<tr>
			<td class="style2">
		<strong>
					&nbsp;&nbsp;&nbsp;<asp:Button runat="server" Text="Add Item" id="Button6" Width="103px" PostBackUrl="http://las.laxpm.com/home/dataentry.aspx" /></strong>&nbsp;&nbsp;&nbsp;<asp:Button runat="server" Text="History" id="Button1" Width="100px" PostBackUrl="http://las.laxpm.com/home/historyhome_data.aspx" />&nbsp; &nbsp;<asp:Button runat="server" Text="Ship History" id="Button7" Width="100px" PostBackUrl="http://las.laxpm.com/home/historyhomequerry.aspx" />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
		</tr>
	</table>
	<table style="width: 1300px" cellpadding="0" cellspacing="0" class="style1" align="center">
		<tr>
			<td class="style10"><span class="style18">To delete item use 
			Edit/Update 
			- Change status to closed!</span><br />
			<div class="style10">
				<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" onrowdatabound="GridView1_RowDataBound" DataKeyNames="ID" AllowPaging="True" AllowSorting="True" ShowFooter="True" GridLines="None">
					<RowStyle Font-Names="Arial" Font-Size="8pt" Width="1300px" />
					<Columns>
						<asp:commandfield ShowEditButton="True">
							<ItemStyle HorizontalAlign="Left" Wrap="False" Width="40px" />
						</asp:commandfield>
						<asp:boundfield DataField="Ship" HeaderText="Ship" SortExpression="Ship">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="40px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="Sta" SortExpression="Station">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownListSta" Width="82px" Height="22px" SelectedValue='<%# Bind("Station") %>' DataValueField="Station" DataTextField="Station" DataSourceID="AccessDataSource5">
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource5" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Station] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Station") %>' id="Label9">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="70px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="ArrDate" SortExpression="ArrDate">
							<EditItemTemplate>
								<asp:TextBox runat="server" Text='<%# Bind("ArrDate", "{0:MM/dd/yyyy}") %>' id="ArrDate">
								</asp:TextBox>
								<a href="javascript:;" onclick="window.open('popup.aspx?textbox=ArrDate','cal','width=250,height=225,left=270,top=180')">
								<img src="SmallCalendar.gif" border="0" width="16" height="16"></img></a>
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("ArrDate", "{0:MM/dd/yyyy}") %>' id="Label6">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="ArrTime" DataFormatString="{0:hh:mm.FF tt}" HeaderText="ArrTime" SortExpression="ArrTime">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="DepDate" SortExpression="DepDate">
							<EditItemTemplate>
								<asp:TextBox runat="server" Text='<%# Bind("DepDate", "{0:MM/dd/yyyy}") %>' id="DepDate">
								</asp:TextBox>
								<a href="javascript:;" onclick="window.open('popup.aspx?textbox=DepDate','cal','width=250,height=225,left=270,top=180')">
								<img src="SmallCalendar.gif" border="0" width="16" height="16"></img></a>
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("DepDate", "{0:MM/dd/yyyy}") %>' id="Label7">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="DepTime" DataFormatString="{0:MM/dd/yyyy}" HeaderText="DepTime" SortExpression="DepTime">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="Reason" SortExpression="Reason">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownList1" Width="184px" Height="31px" SelectedValue='<%# Bind("Reason") %>' DataValueField="Reason" DataTextField="Reason" DataSourceID="AccessDataSource1">
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Reason] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Reason") %>' id="Label1">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Left" Wrap="False" Width="150px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Workload AOS Description &amp; Work Progession Detail" SortExpression="Workload">
							<EditItemTemplate>
								<asp:TextBox id="tb7" rows="5" TextMode="MultiLine" runat="server" Width="275px" Height="85px" Text='<%# Bind("Workload") %>' />
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Workload") %>' id="Label4">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Left" Width="500px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Parts/Tooling Other Requirements" SortExpression="Parts">
							<EditItemTemplate>
								<asp:TextBox id="tb8" rows="5" TextMode="MultiLine" runat="server" Width="275px" Height="85px" Text='<%# Bind("Parts") %>' />
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Parts") %>' id="Label5">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Left" Width="350px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Updated" SortExpression="Updated">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownList2" DataValueField="Leads" DataTextField="Leads" DataSourceID="AccessDataSource2" Height="31px" Width="184px" SelectedValue='<%# Bind("updated") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource2" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Leads] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Updated") %>' id="Label2">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="150px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Status" SortExpression="Status">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="DropDownList3" DataValueField="Status" DataTextField="Status" DataSourceID="AccessDataSource3" SelectedValue='<%# bind("status") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource3" DataFile="db2.mdb" SelectCommand="SELECT DISTINCT [Status] FROM [Droprdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Status") %>' id="Label3">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="EtrDate" SortExpression="EtrDate">
							<EditItemTemplate>
								<asp:TextBox runat="server" Text='<%# Bind("EtrDate", "{0:MM/dd/yyyy}") %>' id="EtrDate">
								</asp:TextBox>
								<a href="javascript:;" onclick="window.open('popup.aspx?textbox=ArrDate','cal','width=250,height=225,left=270,top=180')">
								<img src="SmallCalendar.gif" border="0" width="16" height="16"></img></a>
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("EtrDate", "{0:MM/dd/yyyy}") %>' id="Label8">
								</asp:Label>
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="ETRTime" DataFormatString="{0:MM/dd/yyyy}" HeaderText="ETR Time" SortExpression="ETRTime">
							<HeaderStyle Wrap="True" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="80px" />
						</asp:boundfield>
					</Columns>
					<FooterStyle BackColor="Navy" Font-Names="Arial" Font-Size="Small" />
					<PagerStyle BackColor="Navy" Font-Names="Arial" ForeColor="White" />
					<HeaderStyle BackColor="Navy" Font-Names="Arial" Font-Size="Small" ForeColor="White" />
					<EditRowStyle Width="1200px" />
					<AlternatingRowStyle BackColor="Blue" ForeColor="White" />
				</asp:GridView>
			</div>
			<asp:AccessDataSource runat="server" ID="AccessDataSource1" DeleteCommand="DELETE FROM [Results] WHERE [ID] = ?" InsertCommand="INSERT INTO [Results] ([Ship], [Station], [ArrDate], [ArrTime], [DepDate], [DepTime], [Reason], [Workload], [Parts], [Updated], [Status], [ETRDate], [ETRTime]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [Results] SET [Ship] = ?, [Station] = ?, [ArrDate] = ?, [ArrTime] = ?, [DepDate] = ?, [DepTime] = ?, [Reason] = ?, [Workload] = ?, [Parts] = ?, [Updated] = ?, [Status] = ?, [ETRDate] = ?, [ETRTime] = ? WHERE [ID] = ?" DataFile="db2.mdb" SelectCommand="SELECT [ID], [Ship], [Station], [ArrDate], [ArrTime], [DepDate], [DepTime], [Reason], [Workload], [Parts], [Updated], [Status], [ETRDate], [ETRTime] FROM [Results] WHERE ([Status] = ?) ORDER BY [ETRDate], [ArrDate]">
				<SelectParameters>
					<asp:parameter DefaultValue="Open" Name="Status" Type="String" />
				</SelectParameters>
				<DeleteParameters>
					<asp:parameter Name="ID" Type="Int32" />
				</DeleteParameters>
				<UpdateParameters>
					<asp:parameter Name="Ship" Type="String" />
					<asp:parameter Name="Station" Type="String" />
					<asp:parameter Name="ArrDate" Type="DateTime" />
					<asp:parameter Name="ArrTime" Type="String" />
					<asp:parameter Name="DepDate" Type="DateTime" />
					<asp:parameter Name="DepTime" Type="String" />
					<asp:parameter Name="Reason" Type="String" />
					<asp:parameter Name="Workload" Type="String" />
					<asp:parameter Name="Parts" Type="String" />
					<asp:parameter Name="Updated" Type="String" />
					<asp:parameter Name="Status" Type="String" />
					<asp:parameter Name="ETRDate" Type="DateTime" />
					<asp:parameter Name="ETRTime" Type="String" />
					<asp:parameter Name="ID" Type="Int32" />
				</UpdateParameters>
				<InsertParameters>
					<asp:parameter Name="Ship" Type="String" />
					<asp:parameter Name="Station" Type="String" />
					<asp:parameter Name="ArrDate" Type="DateTime" />
					<asp:parameter Name="ArrTime" Type="String" />
					<asp:parameter Name="DepDate" Type="DateTime" />
					<asp:parameter Name="DepTime" Type="String" />
					<asp:parameter Name="Reason" Type="String" />
					<asp:parameter Name="Workload" Type="String" />
					<asp:parameter Name="Parts" Type="String" />
					<asp:parameter Name="Updated" Type="String" />
					<asp:parameter Name="Status" Type="String" />
					<asp:parameter Name="ETRDate" Type="DateTime" />
					<asp:parameter Name="ETRTime" Type="String" />
				</InsertParameters>
			</asp:AccessDataSource>
			<br />
			<br />
			<br />
			<br />
			<table style="width: 1100px" cellpadding="0" cellspacing="0" class="style15">
				<tr>
					<td class="style16">&nbsp;</td>
				</tr>
				<tr>
					<td class="style12">&nbsp;</td>
				</tr>
			</table>
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			</td>
		</tr>
	</table>
</form>

</body>

</html>






**********************************************

.cs 


using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Home_data1 : System.Web.UI.Page
{

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
      if (e.Row.RowType==DataControlRowType.DataRow)
                if (e.Row.Cells[8].Text == "AOS" || e.Row.Cells[8].Equals(DBNull.Value))   
                {   
                    e.Row.BackColor = System.Drawing.Color.Yellow;   
                }
 }

}

Open in new window

0
 
sumeetsuviCommented:
Ohh ...I got your Mistake Please do this without this u never able to run your application...A small editing

U have used
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home_data1.aspx.cs" Inherits="home_data1" %>

Here Class Name Is "home_data1"

in .CS file u used "Home_data1" so it giving Error
so change "Home_data1" to "home_data1" only...
0
 
BOEING39Author Commented:
Ok thx.  Changed above page and now loads properly
 with no errors; however, reason "Column" does not highlight when the "AOS" condition is met in the gridview.  Any ideas?  Also, the "Reason column data is populated by a drop template field under update, would that have an effect?

if (e.Row.Cells[7].Text == "AOS" || e.Row.Cells[7].Equals(DBNull.Value))
0
 
sumeetsuviCommented:
I doesn't have ur database so i can't check it ..but,as ur datagrid having "Column Name Reason" It is of 8th form Left including Edit column so it is right to use  cells[7].
Can u send me ur database that i can check it further..
0
 
BOEING39Author Commented:
Here is the data base
db2.mdb
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.