Good Day Guys , i am using RadSilverlight controls and the implementation should be the same with the normal Combobox. But now the List that i get is not what i want or the data that i need. i have a WCF DataLayer Service that has a function that is defined like this
publicIList<AccountsModel> GetAccounts(){con =newSqlConnection(strConccounting);cmdselect =newSqlCommand("usp_Select_Account");cmdselect.CommandType = CommandType.StoredProcedure;da =newSqlDataAdapter();cmdselect.Connection = con;da.SelectCommand = cmdselect;DataTable dt =newDataTable();List<AccountsModel> m_Accounts =newList<AccountsModel>();try{con.Open();da.Fill(dt);if(dt.Rows.Count > 0){for(inti = 0; i < dt.Rows.Count; i++){AccountsModel m =newAccountsModel();m.iAccountID = Convert.ToInt32(dt.RowsIdea[0]);m.sName = dt.RowsIdea[1].ToString();m_Accounts.Add(m);}}}catch(SqlException ex){throwex;}finally{con.Close();}returnm_Accounts;}
and now in my Presentation Layer, my Silverlight App , i want to Bind it to the Combobox. Now normally in asp.net . you would have e.g
ID , that will be Primary key for the record and the "Description" and that will be the Text that will be displayed in the the Dropdownlist. So my setup is the same and i have amodel that is sitting on the Data layer that i forgot to share with you
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.ComponentModel;usingSystem.ServiceModel;usingSystem.Runtime.Serialization;namespaceDAL{publicclassAccountsModel : INotifyPropertyChanged{publiceventPropertyChangedEventHandler PropertyChanged;privateint_iAccountID;privatestring_sName;/// When the Property is changed from the PL this gets Fired/// </summary>/// <param name="property"></param>privatevoidOnPropertyChanged(String property){// DAL objConverter = new DAL();List<AccountsModel> Model =newList<AccountsModel>();if(PropertyChanged !=null){PropertyChanged(this,newPropertyChangedEventArgs(property));//objConverter.Updatedata();}}publicintiAccountID{get{return_iAccountID;}set{_iAccountID = value;OnPropertyChanged("iAccountID");}}publicstringsName{get{return_sName;}set{_sName = value;OnPropertyChanged("sName");}}}}
ok now lets Continue. Now on the Silverlight side , i had a Telerik Combobox that is defined like this in the xaml
<telerik:RadComboBoxHorizontalAlignment="Left"Text="{Binding sName}"Margin="222,80,0,0"Name="ddlaccount"VerticalAlignment="Top"Width="186"Height="26"></telerik:RadComboBox>
and the server side i am creating the BLL Service object and accessing the funtions like this
publicPosting(){InitializeComponent();Loaded +=newRoutedEventHandler(Posting_Loaded);}voidPosting_Loaded(objectsender, RoutedEventArgs e){BLL.BLLServiceClient objBLL =newBLL.BLLServiceClient();objBLL.GetAccountsCompleted +=newEventHandler<BLL.GetAccountsCompletedEventArgs>(objBLL_GetAccountsCompleted);objBLL.GetAccountsAsync();}voidobjBLL_GetAccountsCompleted(objectsender, BLL.GetAccountsCompletedEventArgs e){if(e.Error ==null){ddlaccount.ItemsSource = e.Result;}}
and at the same time , i am binding the Combobox. but the Results i get are not the Values but this

Thanks