Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

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;

                }
            }
        }
0
sutorius
Asked:
sutorius
  • 2
  • 2
1 Solution
 
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

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now