Click here to Skip to main content
15,922,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Silverlight Application,with Code in C# in Visual Studio 2010. My requirement is i have a form with many different controls(Example textboxes,combo boxes). I want to fill data in all these controls from Database,the values are comiing from different tables of the database(like CountryName in Combo from CountryMaster,CityName in Combo from CityMaster) etc.Now how can i construct methods in Service.svc file and access them in my XAML file to populate data in my controls. Combo's should have all the values in particular column of the Table(like All the Country Names should be Added to Combo Control) Also that after selecting All the combo's when a user clicks on a Select button the Selected Record should be displayed in DataGrid.

Thanks in Advance
Posted
Comments
walterhevedeich 4-Aug-11 5:35am    
What have you tried?
Member 8121187 4-Aug-11 5:43am    
no im very much new to silverlight and exploring new things this is my first projetc in silverlight(c#.net).
can u help me out in the easiest way.
Member 8121187 4-Aug-11 5:50am    
//Code of Service File
[OperationContract]
public List<BrMaster> GetBranch()
{
using (Entities context = new Entities())
{
return (from c in context.BranchMasters
select new BrMaster
{
Name=c.Name,
}).Take<BrMaster>(10).ToList< BrMaster>();
}
}


public class BrMaster
{
public string Name { get; set; }
}


//code of Form
private void Page_Loaded(object sender, RoutedEventArgs e)
{
//var client = new Services.ContactServiceClient();
var client= new ServiceReference1.AlumniServiceClient();

client.GetBranchCompleted += (s, ea) =>
{
dataGrid1.AutoGenerateColumns = true;
dataGrid1.ItemsSource = ea.Result;
};
client.GetBranchAsync();
}

this code i have used for DatagridView.
can u help me out it for comboBox???

1 solution

You need to use a web service (or RIA Services) to access your database because Silverlight apps cannot use the various .Net SqlConnection and SqlCommand objects. I think it's simpler to use RIA Services.

MSDN Creating a RIA Services Solution[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900