Problem refilling combobox with LINQ datasource
Posted on 2011-03-11
Simple code that works the first time for a combobox:
Dim dbCPI As New MBCPIDataContext
Dim cnum = From CPI In dbCPI.view_CaseNumbers Select CPI.CaseNumber Distinct
Me.cmb_CaseNumber.DataSource = cnum
Me.cmb_CaseNumber.DisplayMember = "CaseNumber"
Me.cmb_CaseNumber.Sorted = True
I want users to be able to click on a button to refill the combobox if an entry is missing and may have been added to the underlying SQL table. I currently have the button set to just rerun this code. But it does not refill the combobox, even though I know the underlying data has changed. If I first set the datasource to Nothing, then the combobox comes back empty, and never fills. I don't think this is really a LINQ issue. I can see definitively that the LINQ is returning the right dataset, it's just not getting loaded into the combobox.