DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7
  1. #1
    RealGuru Guest

    Combo Box Problem

    HI..I have the following table
    YearsOnline..it has three columns
    CompanyId Year
    ------------- -----
    1 2000
    1 2001
    2 2000

    I have two combo boxes..cboCompany and cboYears
    In the LOAD event of the form I do the following :
    I fill two tables in a dataset..tblCompanies and tblYearsOnline
    and i populate the cboCompanies as follows:

    cboCompanies.DataSource = Ds.Tables("tblCompanies")
    cboCompanies.DisplayMember = "CompanyName"
    cboCompanies.ValueMember = "CompanyId"

    SO I need to POPULATE THE SECOND Combo Box with the years RELATED to the
    company in the FIRST combo box...
    So I tried to put the following code in the cboCompanies.SelectedIndexChanged
    event handler

    Ds.Tables("tblYearsOnline").DefualtView.RowFilter = IIF(cboCompanies.Text.Length
    = 0,0,cboCompanies.SelectedValue
    cboYears.DataSource = Ds.Tables("tblYearsOnline").DefaultView
    cboYears.DisplayMember = "YearsOnLine"
    cboYears.ValueMember = "YearsOnLine"

    THIS IS NOT WORKING..WHAT SHOULD I DO??..PLEASE HELP ME??..I am really frustrated!!!

  2. #2
    RealGuru Guest

    Re: Combo Box Problem

    It is giving an error that it is filling the CompanyId in the RowFIlter statment
    with the following "System.Data.DataRowView".
    The event is getting triggered in the load event!!...before it is even shown!!

  3. #3
    Phil Weber Guest

    Re: Combo Box Problem


    Retina: How is it "not working?" Do you get an error message? If so, what does
    it say, and on which line does it occur?
    Phil Weber

  4. #4
    PWilmarth Guest

    Re: Combo Box Problem

    I'm not sure from your example when you are calling the fill method for your
    data adapter. Until you fill your Data Adapter, you will see this message.
    I'm not sure when, in your code, want to fill your combobox. I worked through
    a combobox problem last week, and that message tells me you have everything
    connected correctly, but you need to fill the Data Adapter.

  5. #5

    Re: Combo Box Problem

    I'm finding that lot's of folks are having this problem. Here is a summary
    of what you need to do to have a properly functioning combobox or list box.

    1. Establish your connection
    2. Add a Data Adapter
    3. Generate your SQL commands
    4. Add a Data Set
    5. Fill your Data Adapter
    6. Bind your data.

    Data binding with comboboxes or listboxes are complex. You can either use
    the properties window (DataSource =, DataView =) or you can do it with code:

    with combobox
    .datasource =
    .dataview =
    end with

  6. #6

    Re: Combo Box Problem

    Sorry,code should be this:

    Code should be this:

    with combobox
    > .datasource =
    > .displaymenber =
    >end with

  7. #7
    RealGuru Guest

    Re: Combo Box Problem

    The tables are getting FILLED with data adapters FINE!..
    no problem in that so I removed that part of the code..I am filling two tables
    in my dataset which are tblCompanies and tblYearsOnline

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.