|
-
Apr 23rd, 2004, 11:20 AM
#1
Thread Starter
New Member
DataBinding with Manually created Dataset
When i use the sqldataadapter wizard i can bind everything perfectly. But now i've resorted to doing all my ado manually because i have more control. I created a sqldataadapter and a dataset, now i would like to bind them to my text boxes and checkboxes. But how come i cant bind like i did when i used the data adapter wizard? is there a way to bind like that without the wizards? I know i can assign them manually ( dr(8) = first.Text ) but i have 400 text boxes i have to bind and that will be very time consuming. Is there another way i can do this?
thanks in advance
-
Apr 23rd, 2004, 01:46 PM
#2
Frenzied Member
You can bind them manually, but you'll have to bind each one in code. After that you won't have to assign values each time the record changes. Here's an example in oledb (bmbQuestion, etc., is an instance of BindingManagerBase):
VB Code:
Private Sub BindControls()
Try
'textboxes on survey tab
txtQuestion.DataBindings.Clear()
txtQuNum.DataBindings.Clear()
txtQuestion.DataBindings.Add(New Binding("Text", dsQuestion, "QS.QText"))
txtQuNum.DataBindings.Add(New Binding("Text", dsQuestion, "QS.Q#"))
'combobox on Survey tab
cboQuNum.DataSource = dsQuestion.Tables("QS")
cboQuNum.DisplayMember = "Q#"
'datagrid in Modules tab
dgModule.DataSource = dsModule
dgModule.DataMember = "[Mod List]"
Catch ex As Exception
MessageBox.Show(ex.Message, "Binding Controls")
End Try
End Sub
'Set BindingManagerBase
Private Sub DoBinding()
Try
bmbQuestion = Me.BindingContext(dsQuestion, "QS") 'survey tab
bmbModule = Me.BindingContext(dsModule, "[Mod List]") 'modules tab
Catch ex As Exception
MessageBox.Show(ex.ToString, "Unable To Bind Base", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
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
|