473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Data bind problem setting default field values

This should be an easy problem for those with far more knowledge than
myself with databinding.

I have a VB.NET 2005 windows form with several checkboxes, textboxes
and datepickers which are bound to a single dataset (running SQL Server
2000). The form also contains a record navigation bar to move through
the records. When the form loads, after assigning the table adapter, I
call the AddNew event which calls a function I have to set the default
values for the checkboxes, textboxes and datepickers. After adding all
of the required data and clicking Save in the navigator toolbar I click
AddNew which again calls my function to assign default values. This is
where things get weird: after assigning all the field values and
clicking save for the second time, if the datepicker date did not
change from the previously added record then NULL is saved to the
database.

It seems that there is some internal event that needs to kick off to
force the value in the datepicker back to the databind/datatable.

Ideas?

Thanks in advance,
CW

Jul 10 '06 #1
1 1905
Continued...
Here is the code I am using:

'Form load
Private Sub Adjustment_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.TblAdjustmentTableAdapter.Fill(Me.PBDVDataSet.t blAdjustment)
BindingNavigatorAddNewItem1_Click(sender, e)
End Sub

Private Sub BindingNavigatorAddNewItem1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BindingNavigatorAddNewItem1.Click
TblAdjustmentBindingSource.AddNew()
InitializeNewRecord()
End Sub
'Sets defaults when "Add New" is clicked
Public Sub InitializeNewRecord()

AdjAddedDTTMDateTimePicker.Value = Today
AdjStartDTDateTimePicker.Value = Today
cmbUserFK.SelectedValue = UserID
chkAllowMultiMatch.Checked = False
chkExpires.Checked = True
AdjAmountTextBox.Text = "0"

End Sub

Private Sub SaveToolStripButton1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SaveToolStripButton1.Click

Me.TblAdjustmentBindingSource.EndEdit()

Me.TblAdjustmentTableAdapter.Update(Me.PBDVDataSet .tblAdjustment)
End Sub

Jul 10 '06 #2

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

Similar topics

14
by: smilemaster | last post by:
I have recently started experiencing form data loss. Here is an example: ====test_form1.php==== <form method="POST" action="test_form2.php"> <input name="textboxvalue" type="text" size="20">...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
4
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
0
by: Hans Koller | last post by:
Hello group, I design a class to bind it to a property grid for easy modification of some settings. My problem is now that I want to raise an event when a settings has been changed. Thats not a...
6
by: pretzla | last post by:
I have a PL/SQL script where I load data from a stored procedure into bind variables. Then, I insert that data from the bind variables into an Oracle table with a simple insert statement. The...
5
by: nagar | last post by:
I'm using data binding to display the values of a dataset in a form. Normally I associate the Text property of the UI element to a field of the dataset. For a specific field, I need to do the...
6
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.