We help IT Professionals succeed at work.

Best way to inform user of successful transaction

mugsey
mugsey asked
on
258 Views
Last Modified: 2010-04-15
I have a foreach loop that loops through a datagrid sending an email for each row like this...

  foreach (GridViewRow row in this.gridView.Rows)
            {
                DataRowView drv = row.DataItem as DataRowView;
                EmailMessage message = new EmailMessage();
                ///////////////////////////
            }

What I want is the best approach to inform the user that all the records have been iterated successfully, with the total amount of records being displayed.
Comment
Watch Question

Commented:
Best way? I dunno, but here are some thoughts.

On most forms/web pages I like having a message area for keeping the user informed of progress. That's where I post status messages like that.  Possibly, also I would post instructions for the next step, making the interaction somewhat wizard like.

What takes more thought, perhaps, is what to do when things go bad.  You could use the same status message approach or you can pop up a form or message box to make the problem very obvious.  It can get tricky, in a case where you are iterating through a list, to designate where the problem occurred and the the status of individual emails if some of them did get sent out and others did not.

 



 
To catch the errors, you will need to use a Try statement... and inside of this, if the Try succeeds, you can count the successful transactions.  Then, after, show that total.  Let me know if you need help.  I work in VB.NET, but I can probably show it in C# too.

Commented:

int errorCount = 0;
int count = 0;
foreach (GridViewRow row in this.gridView.Rows)
            {
                DataRowView drv = row.DataItem as DataRowView;
                EmailMessage message = new EmailMessage();
               
if (error)
{  errorCount++; }
count++;
            }

IN a poup or a status bar or evenbetter the caption of the datagrid.


string errmsg = string.empty
if (errorCount >0)
{ errmsg = errorCount  + " messages failed to send"; }
datagrid.text = count + " number of messages processed. "  + errmsg;

Author

Commented:
Thanks

Could I have another example please folks in c#
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*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.