public class Appsrvvice : IAppsrvvice { public void DoWork() { } public List<fillupcombox> fillup() { List<string> x=new List<string>(); List<string> y=new List<string>(); string connectionstring = "server=localhost;User Id=root;password=root;Persist Security Info=True;database=mv_store"; string msg; msg = ""; MySqlConnection con = new MySqlConnection(connectionstring); MySqlDataAdapter ad = new MySqlDataAdapter("select Product_Name,Product_Id from product_detail Order by Product_Name", con); DataTable dt = new DataTable(); try { ad.Fill(dt); // return dt; for(int i=0;i<dt.Rows.Count;i++) { x.Add(dt.Rows[i]["Product_Name"].ToString()); y.Add(dt.Rows[i]["Product_Id"].ToString()); } } catch (Exception e) { msg = e.Message; return null; } finally { ad.Dispose(); } return new List<fillupcombox>() { new fillupcombox() { Texts=x, Valuess=y } }; } } [ServiceContract] public interface IAppsrvvice { [OperationContract] void DoWork(); [OperationContract] List<fillupcombox> fillup(); } [DataContract] public class fillupcombox { [DataMember] public List<string> Texts { get; set; } [DataMember] public List<string> Valuess { get; set; } } Heres My main page code public MainPage() { InitializeComponent(); ServiceReference1.AppsrvviceClient obj = new ServiceReference1.AppsrvviceClient(); obj.fillupCompleted += new EventHandler<ServiceReference1.fillupCompletedEventArgs>(fillupCompletedp); obj.fillupAsync(); } public void fillupCompletedp(object sender, ServiceReference1.fillupCompletedEventArgs e) { comboBox1.ItemsSource =e.Result; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)