troubleshooting Question

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

Avatar of rtay
rtayFlag for United States of America asked on
C#Windows OS
1 Comment1 Solution137 ViewsLast Modified:
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);
                }
            }
ASKER CERTIFIED SOLUTION
Dustin Saunders
Co-Founder and Chief Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2016

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros