Hi,
How will I bind combobox with database in silverlight application. plz, help me.
Thanks, in advance
How to bind combobox with database
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 13, 2011, 8:50 PM EDT
Try this Links, Link1 Link2
--------------------------------------------------------------
If this helps you,then mark as "Correct Answer"
Priya LingeRank #785 · 2.9K reputationPosted Sep 13, 2011, 8:51 PM EDT
You can bind combobox as following way,
We have Service.svc.cs :
[OperationContract]
public List data()
{
con.Open();
string qry = "select Name from Customer";
SqlCommand cmd = new SqlCommand(qry, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
list.Add(dr[0].ToString());
}
con.Close();
return list.ToList();
}
Access data at client side, in MainPage.xaml.cs as below,
public void getdata()
(service_dataCompleted);
{
service.dataCompleted += new EventHandler
service.dataAsync();
}
void service_dataCompleted(object sender, ServiceReference1.dataCompletedEventArgs e)
{
items = e.Result.ToList();
for (int i = 0; i < items.Count; i++)
{
comboBox1.Items.Add(items[i].ToString());
//Here we bind data with combobox from service method
}
}
Hope this will help you.
Thanks.