Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Reset button functionality in C#

Posted on 2004-10-25
Medium Priority
Last Modified: 2008-02-01
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
Question by:anagm
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
  • 2
  • 2

Expert Comment

ID: 12406295
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

private string m_origName,m_origAddress,m_origZip;
private bool m_flg=false;
public void OnLoad(...)
    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(...)
   Name.Text = m_origName;
   Address.Text = m_origAddress;
   Zip.Text = m_origZip;

Please tell me if this helps
LVL 18

Accepted Solution

armoghan earned 1500 total points
ID: 12407497
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

Author Comment

ID: 12410519
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

Author Comment

ID: 12412414
armoghan, can you give an example
LVL 18

Expert Comment

ID: 12418679
You need to implement ICloneable Interface on the object.
see this as a start up

see the reference of IConeable from MSDN

see this example for generic method of cloning.

Now you keep a copy on server side or Session and reset to it when required

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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