|
-
Feb 16th, 2005, 02:16 PM
#1
Thread Starter
New Member
Problem with bound textbox and integers
I've got a data entry form with databindings on the text property to members of a dataset. I then use a Currency Manager to add or edit. There is also some simple validation on the textbox Validating event and an Error Provider.
Everything is fine for strings (nvarchars column in SQL Server) in the textboxes. But with Integer/Int32 (int column in SQL Server) there is very strange behaviour:
1. Delete the textbox entry (allowed) and move elsewhere (by keyboard or mouse) and the number miraculously reappears!
2. Enter something invalid (e.g. alphabetic) move off the textbox and again the original number returns!
Contents of the textbox are ok just prior to ending the Validating code. But contents have changed back when in the Validated event. Almost like a Currency Manager EndCurrentEdit.
(VS.NET 2005 Beta and SQL Server Express 2005).
Just can't work it out. Any ideas out there?
zapo
-
Feb 17th, 2005, 04:05 AM
#2
Thread Starter
New Member
Re: Problem with bound textbox and integers
Comment out the Validating code and still it happens.
I think it's something to do with the databinding to the textbox. StudentNumber is the integer one, all the others are strings:
Private Function BindControls(ByVal ds As DataSet) As CurrencyManager
Dim dt As DataTable = ds.Tables("Students")
Dim ctl As Control
For Each ctl In Me.Controls
ctl.DataBindings.Clear()
Next
txtStudentNumber.DataBindings.Add("Text", dt, "StudentNumber")
txtFirstName.DataBindings.Add("Text", dt, "FirstName")
txtLastName.DataBindings.Add("Text", dt, "LastName")
txtAddress1.DataBindings.Add("Text", dt, "Address1")
txtAddress2.DataBindings.Add("Text", dt, "Address2")
txtAddress3.DataBindings.Add("Text", dt, "Address3")
txtAddress4.DataBindings.Add("Text", dt, "Address4")
txtPostCode.DataBindings.Add("Text", dt, "PostCode")
txtPhone1.DataBindings.Add("Text", dt, "Phone1")
txtPhone2.DataBindings.Add("Text", dt, "Phone2")
txtPhone3.DataBindings.Add("Text", dt, "Phone3")
txtEmail.DataBindings.Add("Text", dt, "Email")
txtComment.DataBindings.Add("Text", dt, "Comment")
Return CType(Me.BindingContext(dt), CurrencyManager)
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|