c# - Refresh WPF Datagrid not bound to observable collection? -


i using linq sql datagrid , binding data auto generated fields. data updates fine when when submitting changes via linq. problem having cannot seem refresh updated data after run sql statement on database directly. databases data updated correctly , closing down , re-starting application data updated correctly.

i have tried,

mytable.items.refresh(); 

and

private databasedatacontext sql = new databasedatacontext(             properties.settings.default.staffconnectionstring);  sql.refresh(system.data.linq.refreshmode.overwritecurrentvalues); 

the xaml used bind data datagrid column, info_data auto generated field database table.

<datagridtemplatecolumn header="info" width="*" sortmemberpath="words">                                 <datagridtemplatecolumn.celltemplate>                                     <datatemplate>                                         <textblock fontweight="light" text="{binding path=info_data, updatesourcetrigger=propertychanged}" />                                     </datatemplate>                                 </datagridtemplatecolumn.celltemplate> 

by accounts seems need create observable collection , bind data , update collection refresh data-grid table. there way around this?

you try sqldataadapter , datatable load info database , bind datagrid:

var da = new sqldataadapter("select * " + view, conn); var dt = new datatable(); da.fill(dt); var dg = new datagrid();// datagrid dg.itemssource = dt.defaultview; 

on update:

dt.rows.clear(); da.fill(dt); dt.acceptchanges(); 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -