This is a migrated thread and some comments may be shown as answers.

Need Help on RadProgressArea

1 Answer 85 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Han
Top achievements
Rank 1
Han asked on 19 Jan 2012, 02:49 PM
Hi,

Can you show me how to use RadProgressArea while loading data from a sql server?  Here is my scenario:

I have a RadButton.  when a user click on this button, I have a function call RetrieveData() and this function will connect to a sql database and query about 100,000 records and performing a lot of data manipulation so it will take awhile to produce desire data.

while processing the data, I would like to display like a progress bar so user can see what's going on and wait.  I found the demo here:
http://demos.telerik.com/aspnet-ajax/upload/examples/customprogress/defaultcs.aspx and really like it, but I don't know how to apply it to my scenario.  From the example, it sets the total process = 100, but in my case, my query run can take up to 3 minutes.  Please provide code as possible.  Here is my code behind page:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Do not display SelectedFilesCount progress indicator.
            RadProgressArea1.ProgressIndicators &= ~ProgressIndicators.SelectedFilesCount;
        }
  
        RadProgressArea1.Localization.Uploaded = "Total Progress";
        RadProgressArea1.Localization.UploadedFiles = "Progress";
        RadProgressArea1.Localization.CurrentFileName = "Please wait while updating database... ";
    }

protected void RetrieveData()
{
        //using LINQ to SQL to select data
}

private void UpdateProgressContext()
    {
  
        RadProgressContext progress = RadProgressContext.Current;
  
        const int total = 100;
  
        progress.Speed = "N/A";
        for (int i = 0; i < total; i++)
        {
            progress.PrimaryTotal = 1;
            progress.PrimaryValue = 1;
            progress.PrimaryPercent = 100;
  
            progress.SecondaryTotal = total;
            progress.SecondaryValue = i;
            progress.SecondaryPercent = i;
  
            progress.CurrentOperationText = "Step " + i.ToString();
  
            if (!Response.IsClientConnected)
            {
                //Cancel button was clicked or the browser was closed, so stop processing
                break;
            }
  
            progress.TimeEstimated = (total - i) * 100;
             
            //Stall the current thread for 0.1 seconds
            System.Threading.Thread.Sleep(50);
        }
    }

protected void RadButton1_Click(object sender, EventArgs e)
   {
       UpdateProgressContext(); //I assume this is how it call
       RetrieveData();
   }
Please help, thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 19 Jan 2012, 03:56 PM
Hello Han,

I've already answered you in the other forum thread, so you can check the reply there.
 
All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Upload (Obsolete)
Asked by
Han
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or