|
-
Oct 22nd, 2009, 04:46 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Form Populate
I have this form Customer which is designed with labels, textboxes and comboboxes. I want to populate them by way of databinding. How can i do this??
-
Oct 22nd, 2009, 05:17 AM
#2
Re: Form Populate
If you have defined a datasource at design time, you can specify the property you want to bind and populate from that datasource.
Since you have not provided much information, I'll just explain with illustration. I assume that you have created the dataset & binding source at design time and have a textbox you want to bind to this dataset.
So open the properties of this textbox, and expand the DataBindings node. You will see all the properties that can be bound. Chooose the property you want to bind. For textbox, you would bind the Text property to display. Click the combo dropdown beside it and choose the field to bind it to. (see attached screenshot.)

Just in case you are creating your datasource from code, you need to create the databindings there.
For e.g. something like this should work:
vb.net Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.DataBindings.Add "Text", TheDataSource, TheDataMember) End Sub
Last edited by Pradeep1210; Oct 22nd, 2009 at 05:21 AM.
-
Oct 22nd, 2009, 05:37 AM
#3
Thread Starter
Hyperactive Member
Re: Form Populate
Thanks for your prompt reply Pradeep.
I have binded the textbox to the datasource as you described. But after launching the application the data is not showing up in the textbox. For eg. on startup i want to show details of Client_ID no:1. How can i do this?
Lux.
-
Oct 22nd, 2009, 06:00 AM
#4
Re: Form Populate
Are you sure you have populated your datasource before you are expecting it to be shown there in the controls?
-
Oct 22nd, 2009, 06:15 AM
#5
Thread Starter
Hyperactive Member
-
Oct 22nd, 2009, 06:52 AM
#6
Re: Form Populate
Are you databinding at design time or from code?
You might need to call the DataBind method after you have set the bindings:
vb Code:
TextBox1.DataBindings.Add "Text", TheDataSource, TheDataMember) TextBox1.DataBind()
-
Oct 31st, 2009, 01:10 PM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED] Form Populate
oki got it!!! thanks.. and what do i have to do when i need to update the dataset??
-
Nov 1st, 2009, 10:49 AM
#8
Re: [RESOLVED] Form Populate
call DataAdapter.Update method
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
|