IntroductionADO.Net Classe is Absent in Silverlight That why some time Developer get confused How Retrieve Data in Silvrelight Application? Silverlight Provide ServiceModel Class You Thought this Class You can Call Web services ,WCF Services , RIA Services, Syndication (Rss,Atom) To Get Data. For Communicate with Data Base Web Prefer to Use Entity Framework Or We Can Use Linq to Sql, ADo.net Also through Services Steps By Step ImplementationHere i am try to Retrieve Data form Sql in my DataGridControl 1 Create Silverlight Application. 2 Add DataGrid Control and set its Properties . 3 Add Web Service to you Asp.net Application Where u display Silverlight Application (.XAP).
4 Add EntityFramework Data Model and Connect it to Database Thought Wizard. 5 Add any Table to your EntityFramework Data Mode Like (Products). 6 Add Function in your webservice (MydataServices.asmx.cs) . 7 Set return Type to List tableName type like List. 8 Add Linq Select Qurey and return toList() . 9 Add Service in you Silver light Application in Service References 10 Create load function call Service and Service Completed Event 11 on Completed ( EventArgs e ) Retrieve e.result.tolist() , 12 assigned to DataGrid Item Source Property that's all press F5 and run application. Sample Project SourceDownload source files-1.8MB |