We help IT Professionals succeed at work.
Get Started

Syntax Error in C# Web Form

jjrr007 asked
Last Modified: 2013-12-17
I am working with a webform.  Using the C# code below in the snippet, I am generating the following syntax error:

Error      1      The type or namespace name 'GridViewRowEventArgs' could not be found (are you missing a using directive or an assembly reference?)      C\...Default.aspx.cs      1

I wanted to please ask for some assistance on resolving the syntax error and ensuring that it works.  This code should set a field to have a red background when a column's existing value is N/A.  This should occur when the GridView is being updated (not the new value).   The value of the color is in the textbox called TextBox3.  Also, the label is called Label4.  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Web.UI.WebControls.Adapters;
using System.Web.UI.WebControls.WebParts;
using System.Windows.Forms;
public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    protected void GridView1_RowUpdated(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            Label lbl = (Label)e.Row.FindControl("Label4");
            if ((string)DataBinder.Eval(e.Row.DataItem, "TextBox3") == "N/A")
                lbl.BackColor = System.Drawing.Color.Red;
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE