Hi,
How will I bind data with DataGrid in silverlight.
Thanks, in advance
Data binding with datadrid in silverlight
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Prabhu RajaRank #861 · 2.6K reputationPosted Sep 6, 2011, 8:33 PM EDT
-------------------------
If this helps you then mark it as "Correct Answer"
Priya LingeRank #785 · 2.9K reputationPosted Sep 6, 2011, 8:40 PM EDT
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.