c# - WPF Combobox DataBound to a DataTable, Refresh automatically -
i have 1 combobox
databinding
datatable
fetching data database follows:
sqldataadapter adp = new sqldataadapter (@"select [categoryid],[categoryname]from [northwind].[dbo].[categories]", @"integrated security=sspi;initial catalog=northwind;data source=akshay-pc\sqlexpress"); datatable tbl = new datatable(); adp.fill(tbl); cmbcities.itemssource = ((ilistsource)tbl).getlist(); cmbcities.displaymemberpath = "[categoryname]"; cmbcities.selectedvaluepath = "[categoryid]";
when table data changed(added/removed rows), combobox
not refreshed because ilist
not have change notification built it.
is there way can made possible?
if it's not possible, there way "refresh" databinding datatable
fetch data again. in case, execute above code when window initialized , refresh again without needing execute same code again. cmbcities.data.refresh()
.
what using observablecollection storage data after fetching db?
http://wpflog.blogspot.com/2009/04/very-simple-observablecollection.html
Comments
Post a Comment