wcf - Binding datagrid in silverlight from database using ADO.Net -
i trying bind silverlight pivotgrid sql database using ado.net. purpose have added wcf service , interacting local database , passing data silverlight project, able receive datasource property of pivotgrid control , unable bind pivotgrid control.
below method have written in wcf service
public dataset getdata() { string connstr = "server=sys3248\\sqlexpress; database=employeedb; integrated security=true;"; sqlconnection conn = new sqlconnection(connstr); sqldataadapter da = new sqldataadapter("select * employee", conn); dataset ds = new dataset(); da.fill(ds); return ds; }
here .xaml file
<usercontrol x:class="optimityv5.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" d:designheight="300" d:designwidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"> <grid x:name="layoutroot" background="white"> <dxpg:pivotgridcontrol x:name="pivotgridcontrol1"> <dxpg:pivotgridcontrol.fields> <dxpg:pivotgridfield name="names" fieldname="empname" area="rowarea"/> </dxpg:pivotgridcontrol.fields> </dxpg:pivotgridcontrol> </grid> </usercontrol>
below .xaml.cs
public mainpage() { initializecomponent(); wcfreference.service1client obj = new wcfreference.service1client(); obj.getdataasync(10); obj.getdatatabledataasync(); obj.getdatatabledatacompleted += new eventhandler<wcfreference.getdatatabledatacompletedeventargs> (obj_getdatatabledatacompleted); } void obj_getdatatabledatacompleted(object sender, wcfreference.getdatatabledatacompletedeventargs e) { //pivotgridcontrol1.datasource = e.result.any1.tostring(); var data = e.result.any1.tostring(); xdocument xdoc = xdocument.parse(data); list<string> lstnodes = new list<string>(); foreach (xnode item in xdoc.descendants("empname")) { lstnodes.add(item.tostring()); } pivotgridcontrol1.datasource = lstnodes; // pivotgridcontrol1.datacontext = lstnodes; }
i able see data in datasource property of pivotgridcontrol1, not getting bind control.
can issue.
thanks in advance.
Comments
Post a Comment