Highlight the row background in FormView

Currently I am highlighting the actual controls in the row. There's been a change in the requirement and I need to highlight the entire row that contains the controls. I've looked at Parent but that highlights the entire table. Can you assist? Here is the current code.

private void HighlightErrors(string sColumnName, string sErrorText)
        {
            string sFindName = sColumnName + "TB";
            FormViewRow rowView = (FormViewRow)FormView1.Row;
            Control rvControl = rowView.FindControl(sFindName);

            if (rvControl != null)
            {
                Type t = rvControl.GetType();
                if ((t.ToString() == "System.Web.UI.WebControls.TextBox") || (t.ToString() == "Anthem.TextBox"))
                {
                    System.Web.UI.WebControls.TextBox tb = (TextBox)rvControl;
                    tb.Attributes.CssStyle.Add("background-color", "yellow");
                    tb.ToolTip = sErrorText;
                   
                }
            }

            // Special handling is required for textboxes containing dropdown descriptions
            sFindName = sColumnName + "_descTB";
            rvControl = rowView.FindControl(sFindName);

            if (rvControl != null)
            {
                Type t = rvControl.GetType();
                if (t.ToString() == "Anthem.TextBox")
                {
                    Anthem.TextBox tb = (Anthem.TextBox)rvControl;
                    //tb.BackColor = Color.Yellow;
                    tb.Attributes.CssStyle.Add("background-color", "yellow");
                    tb.ToolTip = sErrorText;
                }
            }

            sFindName = sColumnName + "ERR";
            rvControl = rowView.FindControl(sFindName);

            if (rvControl != null)
            {
                Type t = rvControl.GetType();
                if (t.ToString() == "System.Web.UI.WebControls.Label")
                {
                    Label lbl = (Label)rvControl;
                   
                    lbl.Visible = true;
                    lbl.ToolTip = sErrorText;

                }
            }
        }
LVL 2
sutoriusAsked:
Who is Participating?
 
naveenkohliCommented:
0
 
sutoriusAuthor Commented:
I appreciate your suggestion however there is no OnRowCreated in FormView. According to the VS2005 Documentation there a Cells properties in FormViewRow which states, "Gets a collection of TableCell objects that represent the cells of a row in a Table control. (Inherited from TableRow.) ". However the examples it is using is creating table cells/rows. I just need to set the property of an existing row (on the controls already reside on). I don't see how to do that.
0
 
naveenkohliCommented:
Oops.. my bad.. I did not see it was for FormView and not GridView.
0
 
sutoriusAuthor Commented:
naveenkohli thanks for your help. We ended up using javascript. elementbytagname and elementbyid.
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.