473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Binding Example

I cant seem to find a proper example anywhere that binds a textbox by code.

I have created on the FormLoad a Dataset that has 1 record from my table.
I created a DataRow that holds that record. ( with my columns that were
specified from my commandText.

So what I have done now is I created a textbox on my form.
How do I bind that text box to my DataRow that holds all my columns?
-So It displays the data in the text field, and later so I can put a
"save" button on the form and update the data from the text field back
to the database.

Im using vb.net express and sqlExpress

Thanks

Miro
Oct 21 '07 #1
3 1114
So far, the closest Ive got is this:
TextBox1.Text = CStr(dr("FirstName"))
TextBox2.Text = CStr(dr("LastName"))

its not really binding the value - just displaying it in the textbox.

Im assuming there is a better way however.
(Trying to stay clear of drag and drop wizard )
Miro wrote:
I cant seem to find a proper example anywhere that binds a textbox by code.

I have created on the FormLoad a Dataset that has 1 record from my table.
I created a DataRow that holds that record. ( with my columns that were
specified from my commandText.

So what I have done now is I created a textbox on my form.
How do I bind that text box to my DataRow that holds all my columns?
-So It displays the data in the text field, and later so I can put a
"save" button on the form and update the data from the text field back
to the database.

Im using vb.net express and sqlExpress

Thanks

Miro
Oct 21 '07 #2
TextBox1.DataBindings.Add("text", dr, "FirstName")
TextBox2.DataBindings.Add("text", dr, "LastName")

On Sun, 21 Oct 2007 12:54:37 -0400, Miro <mi******@beero.netwrote:
>So far, the closest Ive got is this:
TextBox1.Text = CStr(dr("FirstName"))
TextBox2.Text = CStr(dr("LastName"))

its not really binding the value - just displaying it in the textbox.

Im assuming there is a better way however.
(Trying to stay clear of drag and drop wizard )
Miro wrote:
>I cant seem to find a proper example anywhere that binds a textbox by code.

I have created on the FormLoad a Dataset that has 1 record from my table.
I created a DataRow that holds that record. ( with my columns that were
specified from my commandText.

So what I have done now is I created a textbox on my form.
How do I bind that text box to my DataRow that holds all my columns?
-So It displays the data in the text field, and later so I can put a
"save" button on the form and update the data from the text field back
to the database.

Im using vb.net express and sqlExpress

Thanks

Miro
Oct 21 '07 #3
Thanks Jack,

That got me on the right track.

I had to put the table name however into the
TextBox1.DataBindings.Add("text", dsStaff.Tables("StaffPerson"),
"FirstName")

Thanks for your help.

Miro

Jack Jackson wrote:
TextBox1.DataBindings.Add("text", dr, "FirstName")
TextBox2.DataBindings.Add("text", dr, "LastName")

On Sun, 21 Oct 2007 12:54:37 -0400, Miro <mi******@beero.netwrote:
>So far, the closest Ive got is this:
TextBox1.Text = CStr(dr("FirstName"))
TextBox2.Text = CStr(dr("LastName"))

its not really binding the value - just displaying it in the textbox.

Im assuming there is a better way however.
(Trying to stay clear of drag and drop wizard )
Miro wrote:
>>I cant seem to find a proper example anywhere that binds a textbox by code.

I have created on the FormLoad a Dataset that has 1 record from my table.
I created a DataRow that holds that record. ( with my columns that were
specified from my commandText.

So what I have done now is I created a textbox on my form.
How do I bind that text box to my DataRow that holds all my columns?
-So It displays the data in the text field, and later so I can put a
"save" button on the form and update the data from the text field back
to the database.

Im using vb.net express and sqlExpress

Thanks

Miro
Oct 22 '07 #4

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

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
11
by: Rourke Eleven | last post by:
I have looked and searched. What good is the databind property on Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set...
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
0
by: Larry Serflaten | last post by:
I am not sure how many are aware of this sort of data binding, but as it is new to many (classic) VB developers I thought I would post this once just to let people know of its availablility. ...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
9
by: Miro | last post by:
VB 2003 and Im still new to vb, so i hope i can explain this as best I can. I have a variable defined as such: ( simple example ) Dim AVariableOfSorts(,) As Object = _ { _ {"Last", "String",...
15
by: Tom Gur | last post by:
Hi, What is early/late binding ?
3
ADezii
by: ADezii | last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.