Hi,
How will I bind data with DataGrid in silverlight.
Thanks, in advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Priya LingePosted Sep 7, 2011, 12:40 AM
You can bind data by following way,
we have service name datagridservice.svc.cs
in that take data from sql tables,
[OperationContract]
public List getdata()
{
DataClasses1DataContext db = new DataClasses1DataContext();
var result = from c in db.Customers select c;
return result.ToList();
}
MainPage.xaml
<sdk:DataGrid AutoGenerateColumns="True" Height="100" HorizontalAlignment="Left" Margin="76,14,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="260" />Bind data with datagrid as follow,
public void getdata()(service_getdataCompleted);
{
service.getdataCompleted += new EventHandler
service.getdataAsync();
}
void service_getdataCompleted(object sender, ServiceReference1.getdataCompletedEventArgs e)
{
dataGrid1.ItemsSource = e.Result;
}
Hope this will help you.
Thanks.
Prabhu RajaPosted Sep 7, 2011, 12:33 AM
-------------------------
If this helps you then mark it as "Correct Answer"