c# - How after updating data from one of the UI (at network) reload data at other UIs and keep relatioship? -
when add entity data model mysql database wpf application , collectionviewsource created both parent , child tables like:
<collectionviewsource x:key="topicmainviewsource" d:designsource="{d:designinstance {x:type dbmrcpe:topicmain}, createlist=true}"/> <collectionviewsource x:key="articlesrelatedviewsource" source="{binding topicsublev1, source={staticresource topicmainviewsource}}"/> and create datacontext grid , binding radgridviews like
<grid name="maingrid" datacontext="{staticresource topicmainviewsource}"> <telerik:radgridview x:name="topicmaingridview" datamember="idtopicmain" itemssource="{binding}" /> <telerik:radgridview x:name="articlesrelatedradgridview" itemssource="{binding source={staticresource articlesrelatedviewsource}}" /> </grid> and code load data @ cs
dbmrcpe.dbmrcpnephrologyentities ctx = new dbmrcpe.dbmrcpnephrologyentities(); private void window_loaded(object sender, routedeventargs e) { ctx = new dbmrcpe.dbmrcpnephrologyentities(); system.windows.data.collectionviewsource topicmainviewsource = ((system.windows.data.collectionviewsource)(this.findresource("topicmainviewsource"))); // load data setting collectionviewsource.source property: topicmainviewsource.source = ctx.topicmains; } the question : if user add data gridview @ runtime , how reload data other user interfaces @ runtime if refersh button used without loos relation ship between 2 grids?
thanks ever 1 solved after question
by add new referance datacontext like
private void reloadbtn_click(object sender, routedeventargs e) { dbmrcpe.dbmrcpnephrologyentities ctx2 = new dbmrcpe.dbmrcpnephrologyentities(); ctx = ctx2; topicmainviewsource.source = ctx.topicmains; } if use topicmainviewsource.source = ctx.topicmains; directly not load new data want use ctx.savechanges() allover code
Comments
Post a Comment