Link to home
Start Free TrialLog in
Avatar of rtay
rtayFlag for United States of America

asked on

C# Windows Form Search Gridview from databound combobox using foreign key

I have a windows form with a Gridview linked to a dataset.  I want to filter the gridview by a databound combobox which shows the display member but searches by the value member.  The datasource of the combobox is bound to a table that links to the gridview table with a foreign key.  So the value I need to filter by ultimately is an Int, but that would not make sense to the user, so the display member is the descriptive text value.  When writing the code behind, I get an error cannot convert from string to text.  This makes me believe that I did not configure it correctly to pass the int to the filter, and it is trying to use the text that is displayed in the combobox.  Any suggestions?

  private void button1_Click(object sender, EventArgs e)
        {
            try

                {
                    this.tbl_RateTableAdapter.FillBy(this.ds_FeedRatebyCommodity.tbl_Rate, comboBox1.Text);
                }

                catch (System.Exception ex6)

                {
                    System.Windows.Forms.MessageBox.Show(ex6.Message);
                }
            }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dustin Saunders
Dustin Saunders
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial