Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get data in one combo at the SelectionChanged event of other combo in Silverlight
    primarykey
    data
    text
    <p>My application is in Silverlight(c#.Net)</p> <p>I have a form with three combo boxes,Country,State,City.</p> <p>My requirement is I want to populate my State Combo box at the Selectionchanged Event of Country combo box.</p> <p>When the user select some country than the State of that Country should be populated in State combo.</p> <p>Database Tables:</p> <ul> <li>Country Table-(CountryID,CountryName)</li> <li>State Table-(StateID,StateName,CountryId)</li> <li>City Table-(CityID,CityName,StateId)</li> </ul> <p>To retrieve value from Database im coding in Service.svc.cs File</p> <p>This is my Code. This code will get Country Record.</p> <pre><code> public class GetCountry { public string CountryName { get; set; } } [OperationContract] public List&lt;GetCountry&gt; GetCountryRecord() { using (Entities context = new Entities()) { return (from c in context.CountryMasters select new GetCountry { CountryName = c.CountryName, }).ToList&lt;GetCountry&gt;(); } } //Code to Get State from State_Master table public class GetState { public string StateName { get; set; } } [OperationContract] public List&lt;GetState&gt; GetStateRecord(int countryId) { using (Entities context = new Entities()) { return (from c in context.StateMasters select new GetState { StateName = c.StateName, }).ToList&lt;GetState&gt;(); } } //End of State Code </code></pre> <p>This is my code in Form.xaml.cs. It will populate countries in Country combo box</p> <pre><code> client = new ServiceReference1.AlumniServiceClient(); client.GetCountryRecordCompleted += (s, ea) =&gt; { cboCountry.ItemsSource = ea.Result.Select(b =&gt; b.CountryName).ToList(); }; client.GetCountryRecordAsync(); </code></pre> <p>Please Suggest me Changes in the query in my Service.svc.cs file to get my required result or any other way to get it.</p> <pre><code> return (**from c in context.StateMasters select new GetState** </code></pre> <p>This is my code in Form.xaml.cs at selectionChanged Event of Country Combobox</p> <pre><code> private void cboCountry_SelectionChanged(object sender, SelectionChangedEventArgs e) { var client = new ServiceReference1.AlumniServiceClient(); client.GetStateRecordCompleted += (s, ea) =&gt; { cboState.ItemsSource = ea.Result.Select(b =&gt; b.StateName).ToList(); }; client.GetStateRecordAsync(); } </code></pre> <p>But this will get me All the States present in the StatesMaster</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload