Hi,
How will I bind combobox with database in silverlight application. plz, help me.
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 14, 2011, 12:51 AM
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.
Prabhu RajaPosted Sep 14, 2011, 12:50 AM
Try this Links, Link1 Link2
--------------------------------------------------------------
If this helps you,then mark as "Correct Answer"