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. vb.net 2005 DataBinding to controls

vb.net 2005 DataBinding to controls

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasesalestutorial
4 Posts 2 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.
  • T Offline
    T Offline
    Taen_Karth
    wrote on last edited by
    #1

    Ok, not sure exactly how to word this so here goes. I have a winform in my project that has the following: Controls 1. DropDownList1 - Customer Name 2. TextBox1 - Customer ID 3. DropDownList2 - Site Name DataBase Tables 1. tblCust - Fields(CustName, CustID, Status) 2. tblCustSiteAssoc - Fields(CustId, CustSiteID) 3. tblCustSite - Fields(CustSiteID, CustSiteName, ...) What I am trying to do is this: 1. When the form open have customers names bound to the DropDownList1 control with nothing selected 2. Once I select something in the DropDownList1 control (SelectedIndexChanged) have it update the other two controls with the selected customers' data. I assume I make a DataSet that queries all three tables and I understand how to bind the CustName to the first DropDownList box. What I don't understand is how to use the selected information to get the relevant information for the other two controls. Thanks in advance, Taen Karth

    D 1 Reply Last reply
    0
    • T Taen_Karth

      Ok, not sure exactly how to word this so here goes. I have a winform in my project that has the following: Controls 1. DropDownList1 - Customer Name 2. TextBox1 - Customer ID 3. DropDownList2 - Site Name DataBase Tables 1. tblCust - Fields(CustName, CustID, Status) 2. tblCustSiteAssoc - Fields(CustId, CustSiteID) 3. tblCustSite - Fields(CustSiteID, CustSiteName, ...) What I am trying to do is this: 1. When the form open have customers names bound to the DropDownList1 control with nothing selected 2. Once I select something in the DropDownList1 control (SelectedIndexChanged) have it update the other two controls with the selected customers' data. I assume I make a DataSet that queries all three tables and I understand how to bind the CustName to the first DropDownList box. What I don't understand is how to use the selected information to get the relevant information for the other two controls. Thanks in advance, Taen Karth

      D Offline
      D Offline
      dptalt
      wrote on last edited by
      #2

      When you create your Dataset define a relation between all three tables. It may be better to do this back at the underlying database. Then bind all three controls to the DataSet as you normally would. Now when you select something from DropDownList1 the other two controls will display the proper related data. I hope this helps.

      T 1 Reply Last reply
      0
      • D dptalt

        When you create your Dataset define a relation between all three tables. It may be better to do this back at the underlying database. Then bind all three controls to the DataSet as you normally would. Now when you select something from DropDownList1 the other two controls will display the proper related data. I hope this helps.

        T Offline
        T Offline
        Taen_Karth
        wrote on last edited by
        #3

        Ok I think I need to break this down a little bit more for the relation: Table1 CustID - PriKey - linked to Table2(CustID) CustName Status Table2 CustID CustSiteID Table3 CustSiteID - PriKey - linked to Table2(CustSiteID) CustSiteName Addr1 Addr2 City State etc... I have relationships setup like above. I created a new DataSet Item from Add New Item in IDE. Then it asks me to select Tables which I select the three above. It then adds these three tables to the designer with relationships and TableAdapters configured and all. I then go to DropDownList1 and set the DataSource to the DataSet. It creates a binding source and then I set DisplayMember to CustName and it creates a new TableAdapter. Now I want to select a customer name in DropDownList1 and have it filter DropDownList2 so that only SiteName shows that has a relationship between CustID and CustSiteID. I can only get DropDownList2 to list all SiteName. I can't figure out how to filter it. Thanks, Taen Karth

        D 1 Reply Last reply
        0
        • T Taen_Karth

          Ok I think I need to break this down a little bit more for the relation: Table1 CustID - PriKey - linked to Table2(CustID) CustName Status Table2 CustID CustSiteID Table3 CustSiteID - PriKey - linked to Table2(CustSiteID) CustSiteName Addr1 Addr2 City State etc... I have relationships setup like above. I created a new DataSet Item from Add New Item in IDE. Then it asks me to select Tables which I select the three above. It then adds these three tables to the designer with relationships and TableAdapters configured and all. I then go to DropDownList1 and set the DataSource to the DataSet. It creates a binding source and then I set DisplayMember to CustName and it creates a new TableAdapter. Now I want to select a customer name in DropDownList1 and have it filter DropDownList2 so that only SiteName shows that has a relationship between CustID and CustSiteID. I can only get DropDownList2 to list all SiteName. I can't figure out how to filter it. Thanks, Taen Karth

          D Offline
          D Offline
          dptalt
          wrote on last edited by
          #4

          To filter use a DataView. You could say something like this: DropDownList2.DataSource = DataSet.Table3.DefaultView DropDownList2.DisplayMember = "CustSiteName" But, since you have the tables related to each other I don't think filtering is neccessary. Instead set it up like this: DropDownList2.DataSource = DataSet.Table3 DropDownList2.DisplayMember = "CustSiteName" Since Table3 is in a relation it will show the proper records in DropDownList2 Also, I think you could elliminate Table2 and have CustID in Table3.

          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