Reset button functionality in C#

I am trying to implement the following


Name     Address   ZipCode

x            Jackson    132                 Edit     Reset
(the above data is default)
----------------------------------------------------
I make the changes with 'Edit' Button

Name     Address   ZipCode

x            Simpson    456                 Edit     Reset
--------------------------------------------------------------
When i press the 'Reset' Button, i should get the following(should change to the default values)

Name     Address   ZipCode

x            Jackson    132                 Edit     Reset

How do i tackle this one?

Any help is appreciated.  Its urgent

My application is in ASP.NET and C#.

Can i get an example code
anagmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aacoolCommented:
It's not clear how or when this data is loaded into what kind of data structure - are these just fields or a list view or...?

In any case, the principle should be to maintain a set of corresponding variables in your load method that keep the original values, and then to load the values back in the Reset method

thus,
private string m_origName,m_origAddress,m_origZip;
private bool m_flg=false;
...
public void OnLoad(...)
{
   loadFields(...);
    m_origName = Name.Text;
    m_origAddress = Address.Text;
    m_origZip = Zip.Text;
    m_flg = true; //set flag to indicate we have original values stored
}


public void OnReset(...)
{
  if(m_flg==true)
  {
   Name.Text = m_origName;
   Address.Text = m_origAddress;
   Zip.Text = m_origZip;
  }
}

Please tell me if this helps
0
armoghanCommented:
How I do is, make a clone of the object which you have populated. User can change the object, but when he/she presses the reset button, as you have saved the clone copy, populate it once again
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anagmAuthor Commented:
The data(original values) are loaded into a grid, when the page is initialized.

The original values is a record in the database and it is the first record, with description 'default'.

i am using the <itemtemplates> to load the data into the grid
0
anagmAuthor Commented:
armoghan, can you give an example
0
armoghanCommented:
You need to implement ICloneable Interface on the object.
see this as a start up
http://www.ondotnet.com/pub/a/dotnet/2002/11/25/copying.html?page=2

see the reference of IConeable from MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemicloneableclasstopic.asp

see this example for generic method of cloning.
http://www.codeproject.com/csharp/cloneimpl_class.asp

Now you keep a copy on server side or Session and reset to it when required
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.