473,507 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding new Rows to DataSet which is bound to controls

Hi,

This thing is giving me the sh** and there must be a
simple way of doing this:
I have a form with several bound controls (textboxes,
combos...).

What i want do do is add a new row. The form should show
all the controls empty, then user can fill in values and
by pressing 'Save', save it to the database.

In the constructor I do this:

CustomersDS.CustomersRow nr = ds1.Customers.NewCustomersRow
();
ds1.EnforceConstraints = false; //without this it'll bomb.
ds1.Customers.AddCustomersRow(nr);
this.BindingContext[ds1, "Customers"].Position =
ds1.Customers.Rows.Count;

In the Save button, this:

if(ds1.HasChanges())
sqlDataAdapter1.Update(ds1.GetChanges(););
For some reason I can see the newly added values in ds1
before I do the GetChanges(), but if I check the values in
the DataRow of the DataSet created by ds1.GetChanges(),
all fields are empty.

Would be very grateful if anyone can point out what I'm
doing wrong.

Thanks for your help!
Dom
Nov 16 '05 #1
2 2899
<an*******@discussions.microsoft.com> wrote in news:344801c47163$ba5c2b00
$a*******@phx.gbl:
this.BindingContext[ds1, "Customers"].Position =
ds1.Customers.Rows.Count;


_All_ arrays in .NET are zero based. Set the postition to
ds1.Customers.Rows.Count - 1 and you should be good to go.

Cheers,
Dave
Nov 16 '05 #2
Thnx for your reply, Dave

The Rows.Count was a bit of a red-herring. The problem is
that the new rows are in the dataset after i do the
GetChanges(), but the fields are empty.

Cheers,
Dominic
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3111
by: Dave Elliott | last post by:
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results. I have added the...
2
3614
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
4
5449
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
0
3479
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
0
659
by: Dominic Büschi | last post by:
Hi, This thing is giving me the sh** and there must be a simple way of doing this: I have a form with several bound controls (textboxes, combos...). What i want do do is add a new row. The...
2
2697
by: Aaron Ackerman | last post by:
I cannot a row to this bound DataGrid to SAVE MY LIFE! I have tried everything and I am at a loss. The using goes into add mode with the add button adds his data then updates with the update...
3
4856
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
1450
by: Gummy | last post by:
Hello, I know I can use a Checkboxlist or a RadioButtonList to easily create a list based on the data passed to it. But using what if I wanted to use the same data and based on the data,...
9
424
by: Greg | last post by:
Binding Manager & dataset - won't add record I've got an untyped dataset with controls bound through code. The user can select a question number from a bound combobox, and the question number and...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.