troubleshooting Question

Syntax Error in C# Web Form

Avatar of jjrr007
jjrr007 asked on
.NET ProgrammingC#Editors IDEs
17 Comments1 Solution2768 ViewsLast Modified:
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


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros