Hi,
I am new to Silverlight3 and i want to display the Combo Box(s) with the previously selected country/state. I am using service to call the tables and access the id of the Country/State.Please help me out how to display its Country/State name in the Combo Box.
Thanks in Advance.
Loading
Priya LingePosted Sep 15, 2011, 2:36 AM
Suppose we have 1 combobox in tht have country names
On comboBox1_SelectionChanged event,we can select country which we want
on this event we get name of country,we can pass tht list of names to service
and retriev thier ids.
With the help of ids we can get the names which selected previously in combobox
that names display in other combobox as below,
[OperationContract]
public List data()
{
con.Open();
string qry = "select Name from Customer where id=";
SqlCommand cmd = new SqlCommand(qry, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
list.Add(dr[0].ToString());
}
con.Close();
return list.ToList();
}
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());
}
}
Hope this will help you.
Thanks.