?
Solved

Best way to inform user of successful transaction

Posted on 2007-10-03
5
Medium Priority
?
245 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.
0
Comment
Question by:mugsey
5 Comments
 
LVL 42

Expert Comment

by:dqmq
ID: 20007833
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.

 



 
0
 
LVL 9

Expert Comment

by:divinewind80
ID: 20007848
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.
0
 
LVL 5

Expert Comment

by:Colemss
ID: 20008171

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;
0
 

Author Comment

by:mugsey
ID: 20009390
Thanks

Could I have another example please folks in c#
0
 
LVL 5

Accepted Solution

by:
Colemss earned 2000 total points
ID: 20014755
This is formatted correctly.      

 private void x() {
            int errorCount = 0;
            int count = 0;
            foreach (GridViewRow row in this.gridView.Rows) {
                DataRowView drv = row.DataItem as DataRowView;
                EmailMessage message = new EmailMessage();

                //Assume this is your error check You need to write logic here
                if (error) {
                    errorCount++;
                }

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 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