Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

.AddNew record without clearing the form...

Posted on 2006-06-17
5
Medium Priority
?
340 Views
Last Modified: 2011-10-03
Hello I have a form that is a bunch of combos/texboxes etc and is used strictly for data entry, the customer would like to have the ability after saving the record to have the data stay on the screen, because most of the time the data is nearly identical - strange I know believe me :)

Anyway the form is bound to a typed dataset and after the form is saved, I call a BindingContext...AddNew() to add a new record to the dataset, works beatiful, great.

is there a setting or override to prevent the data from clearing when this method is called?

I have been pulling my hair out for the last week, i.e. saving the dataset to xml, then reloading it back in - major problems there, anyways I would appreciate the help.

I hope some of you have run into this before and have a solution before, it seems sooo damn easy to.

Thanks Josh
0
Comment
Question by:joshcrosby
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
TheAvenger earned 2000 total points
ID: 16934262
You can copy the row instead of just creating a new one. Here is how you can do this:

DataSet1.DataTable1Row row = this.dataSet11.DataTable1.NewDataTable1Row();
row.Column1 = "val1";
row.Column2 = "val2";
this.dataSet11.DataTable1.AddDataTable1Row(row);

object[] items = new object[row.ItemArray.Length];
row.ItemArray.CopyTo(items, 0);
DataSet1.DataTable1Row newRow = (DataSet1.DataTable1Row)this.dataSet11.DataTable1.Rows.Add(items);
0
 
LVL 5

Expert Comment

by:pgloor
ID: 16934288
I don't know about your scenario, but in a similar situation with standard .NET 2.0 BindingSource and BindingNavigator I did something like the following in C#:

1. Added a private field to temporarily store the old value to my code.

  // Private field to keep the previous value
  private string oldValue = "";

2. Added an AddingNew event to my BindingSource with the following code

  // Remember the old value
  oldValue = valueTextBox.Text; // Assuming the name of the input text box is valueTextBox

3. Added a Click event to the Add New Item button of my Binding Navigator with the following code

  // Assign the stored value to the text box
  valueTextBox.Text = oldValue ; // Assuming the name of the input text box is valueTextBox

You should be able to do something similar. It's just a question to finding the right event.

Peter
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 16934316
pgloor: if you have 100 text boxes on a form, it's too much work. It is also a source of error if a new text box is added
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

927 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