Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. 2 combobox from same data source & same data table in VB.Net2005

2 combobox from same data source & same data table in VB.Net2005

Scheduled Pinned Locked Moved Visual Basic
helpcsharpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nilam11
    wrote on last edited by
    #1

    hi i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields - item_code | length | rate xyz | 1000.00 | 2.0 bnm | 500.00 | 1.0 qwe | 300.00 | 0.50 i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how? plz. help me

    Thanks bye

    R N 2 Replies Last reply
    0
    • N nilam11

      hi i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields - item_code | length | rate xyz | 1000.00 | 2.0 bnm | 500.00 | 1.0 qwe | 300.00 | 0.50 i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how? plz. help me

      Thanks bye

      R Offline
      R Offline
      richardw48
      wrote on last edited by
      #2

      Each combo requires its own separate dataview as the datasource. The two dataviews 'point' to the same table. If you don't do this then each combo is using the table's default dataview as the datasource and a selection in one combo then affects the contents of the other. -- modified at 10:26 Sunday 19th August, 2007

      N 1 Reply Last reply
      0
      • N nilam11

        hi i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields - item_code | length | rate xyz | 1000.00 | 2.0 bnm | 500.00 | 1.0 qwe | 300.00 | 0.50 i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how? plz. help me

        Thanks bye

        N Offline
        N Offline
        Naji El Kotob
        wrote on last edited by
        #3

        Hi, Try this... Dim dvItemCode as New DataView(DataTable) Dim dvLength as New DataView(DataTable) Dim dvRate as New DataView(DataTable) ComboBox1.DataSource = dvItemCode ComboBox1.DisplayMember = "Item_Code" ComboBox1.ValueMember = "ID" ComboBox1.DataSource = dvLength ComboBox1.DisplayMember = "Length" ComboBox1.ValueMember = "ID" ... Hope this helps :)

        NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...

        N 1 Reply Last reply
        0
        • N Naji El Kotob

          Hi, Try this... Dim dvItemCode as New DataView(DataTable) Dim dvLength as New DataView(DataTable) Dim dvRate as New DataView(DataTable) ComboBox1.DataSource = dvItemCode ComboBox1.DisplayMember = "Item_Code" ComboBox1.ValueMember = "ID" ComboBox1.DataSource = dvLength ComboBox1.DisplayMember = "Length" ComboBox1.ValueMember = "ID" ... Hope this helps :)

          NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...

          N Offline
          N Offline
          nilam11
          wrote on last edited by
          #4

          hi thanks for immed. reply & sorry for late reply i have done like u said but it shows one error - Error - 'can not bind to the new display member.' ParameterName : newdisplaymember my code is as follows - con.connectionstring = con_str da_combo1.selectcommand =new sqlclient.sqlcommand da_combo1.selectcommand.connection = con str_sql = "select * from dbo.rate_mas" da_combo1.selectcommand.commandtext = str_sql da_combo1.fill(ds,"rate_mas") dim dt as datatable = new datatable("rate_mas") dim dvitemcode as new dataview(dt) dim dvlength as new dataview(dt) dim dvrate as new dataview(dt) combo1.datasource = dvitemcode combo1.displaymember = "item_desc" **** it shows the above said error for immed. following stmt combo1.valuemember = "item_code" ******** error end combo1.datasource = dvlength combo1.displaymember = "length" combo1.valuemember = "id" what can i do to solve this error bye

          Thanks bye

          N 1 Reply Last reply
          0
          • R richardw48

            Each combo requires its own separate dataview as the datasource. The two dataviews 'point' to the same table. If you don't do this then each combo is using the table's default dataview as the datasource and a selection in one combo then affects the contents of the other. -- modified at 10:26 Sunday 19th August, 2007

            N Offline
            N Offline
            nilam11
            wrote on last edited by
            #5

            hi thanks. my problem is solved using two data sets to access same datatable twice. i was doing same datasets to access same table twice. bye.

            Thanks bye

            1 Reply Last reply
            0
            • N nilam11

              hi thanks for immed. reply & sorry for late reply i have done like u said but it shows one error - Error - 'can not bind to the new display member.' ParameterName : newdisplaymember my code is as follows - con.connectionstring = con_str da_combo1.selectcommand =new sqlclient.sqlcommand da_combo1.selectcommand.connection = con str_sql = "select * from dbo.rate_mas" da_combo1.selectcommand.commandtext = str_sql da_combo1.fill(ds,"rate_mas") dim dt as datatable = new datatable("rate_mas") dim dvitemcode as new dataview(dt) dim dvlength as new dataview(dt) dim dvrate as new dataview(dt) combo1.datasource = dvitemcode combo1.displaymember = "item_desc" **** it shows the above said error for immed. following stmt combo1.valuemember = "item_code" ******** error end combo1.datasource = dvlength combo1.displaymember = "length" combo1.valuemember = "id" what can i do to solve this error bye

              Thanks bye

              N Offline
              N Offline
              Naji El Kotob
              wrote on last edited by
              #6

              Hi, first please make sure that you are not trying to assign columns of two different tables to ValueMember and DisplayMember. In your case you have to check that item_desc and item_code belong to rate_mas datatable. Good luck :)

              NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups