We help IT Professionals succeed at work.

Using break but seeing no label text

dba123
dba123 asked
on
188 Views
Last Modified: 2010-04-15
Ok, from one function I'm calling another.  In the called function, I want to halt further processing if I find certain values so I put in some breaks.  But I notice that even if the if statement evaluates to true and sets the label, I don't see the label on my page showing anything.   The label is just a standard web control.

The called function looks like this

       private bool  MyFunction(Grid myGrid)
        {
            bool blnReturn = true;

            for (int i = 0; i < ugGrid.Rows.Count; i++)
            {
                bool blnFailed = false;

                // start at row 2
                if (i > 0)
                {
                    some code here and then...

                    if (CurrentFac > 1)
                    {
                        blnFailed = true;
                        lblMsg.Text = "Some Error Message 1.";
                        break;
                    }

                    if (PreviousFac> -1 && PreviousFac< 0 && CurrentFac< PreviousFac)
                    {
                        blnFailed = true;
                        lblMsg.Text = "Some Error Message 2.";
                        break;
                    }

                    if (NextFac > -1 && NextFac < 1 && CurrentFac > NextFac)
                    {
                        blnFailed = true;
                        lblMsg.Text = "Some Error Message 2.";
                        break;
                    }
                }
                if (blnFailed)
                {
                    blnReturn = false;
                }
            }
            return blnReturn;
        }

Any idea?  Is the break just halting the rest of the function2 or is it halting my entire app?
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
break exits the for loop:

for (int i = 0; i < ugGrid.Rows.Count; i++)

Bob

Commented:
I believe you want to change your breaks to return blnReturn;
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.