Solved

Label Text does not get updated

Posted on 2013-12-14
9
431 Views
Last Modified: 2013-12-20
I am trying to set the text of a label control based on a condition in a loop.

The condition is reached about 10 times during the loop.

The final text value is ->->->->->->->->->->->->->->

The label acts as a progress bar.

There is no error, but the label text does not get updated.

string strProgressChar = "->";
   
      for (int i = 0; i <=8000 ; i++)
       {
                intProgress++;
               
                if (intProgress == intProgressIncrement)  // increment is 300
                {
                    lblProgress.Text = lblProgress.Text + strProgressChar;  // Text is not updated
                    intProgress = 0;
                }

        }  // End  while ((line = sr.ReadLine()) != null)


Any help would be appreciated.

Thanks,
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39718834
I'm not going to be much help here because I don't have access to VS for testing. When update bars do not show progress it's almost always because the processing thread you are attempting to report on is busy so it cannot also update the progress. In other words, it cannot do two things at once. You need to introduce a pause/update/resume logic at short intervals in your coding for the main process or add a second processing thread for the update (Google multi-threaded operations for asp.net) or you could do a progress bar using ajax for polling. Look here.You may need to provide the main process code to get the help you need.

That's my entire contribution to this question.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39718872
You can't do it like this in asp.net

in ASP.Net when you're running that process the entire thing is server side, the page doesn't reload again until after all of the server side code is finished running.

If you wanted to use the label as a progress bar you would need a web service of some kind.

See below for more information:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28283009.html
0
 

Author Comment

by:Dovberman
ID: 39719177
I thought I would need a delay step.  I will try the timer and provide feedback.

Thanks,
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39719294
You can try either the .Refresh method of the label control, or you could invoke whatever your language's equivalent of "DoEvents" is.  I have to use DoEvents in VB programming, but overuse can be a problem, that's why I only use it at certain intervals using the MOD function, i.e. If intRec MOD 100 = 0 Then DoEvents
0
 

Author Comment

by:Dovberman
ID: 39719559
There is no .Refresh method for a label control.
0
 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39719921
Then instead try the Refresh method of the form.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39720314
If this is for asp.net there is no .refresh on the form.
0
 
LVL 8

Accepted Solution

by:
johny_bravo1 earned 300 total points
ID: 39723304
Well Asp.Net gives you more option for display a progress bar rather than using label.

If you are using UpdatePanel use UpdateProgress control.

Alternatively you can use javascript/ jquery, check below links for javascript

http://www.javascriptkit.com/script/script2/progressbar.shtml

http://jqueryui.com/progressbar/#default
0
 

Author Closing Comment

by:Dovberman
ID: 39731224
Thank you
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question