Results 1 to 2 of 2

Thread: DataBinding with Manually created Dataset

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    1

    Angry 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

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    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:
    1. Private Sub BindControls()
    2.         Try
    3.             'textboxes on survey tab
    4.             txtQuestion.DataBindings.Clear()
    5.             txtQuNum.DataBindings.Clear()
    6.             txtQuestion.DataBindings.Add(New Binding("Text", dsQuestion, "QS.QText"))
    7.             txtQuNum.DataBindings.Add(New Binding("Text", dsQuestion, "QS.Q#"))
    8.  
    9.             'combobox on Survey tab
    10.             cboQuNum.DataSource = dsQuestion.Tables("QS")
    11.             cboQuNum.DisplayMember = "Q#"
    12.  
    13.             'datagrid in Modules tab
    14.             dgModule.DataSource = dsModule
    15.             dgModule.DataMember = "[Mod List]"
    16.         Catch ex As Exception
    17.             MessageBox.Show(ex.Message, "Binding Controls")
    18.         End Try
    19.     End Sub
    20.  
    21. 'Set BindingManagerBase
    22.     Private Sub DoBinding()
    23.         Try
    24.             bmbQuestion = Me.BindingContext(dsQuestion, "QS")       'survey tab
    25.             bmbModule = Me.BindingContext(dsModule, "[Mod List]")   'modules tab
    26.         Catch ex As Exception
    27.             MessageBox.Show(ex.ToString, "Unable To Bind Base", MessageBoxButtons.OK, MessageBoxIcon.Error)
    28.         End Try
    29.     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
  •  



Click Here to Expand Forum to Full Width