Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display Checkbox list based on Dropdown selection?
    primarykey
    data
    text
    <p>Following is my code with the business logic. I get below json by calling the webservice and and I deserialized that to the object (as shown in my Entity). Now, I want to display Dropdown with the category selections and once the user select the category it should display checkbox lists of subcategories.</p> <p>As per my below code the dropdown should have "Eat" &amp; "Entertainment" options. And if the user select "Entertainment" then it should display "All", "Movie, &amp; "Bowling" as the checkbox list. Can anyone please help me how to have this in MVC3 &amp; C#?</p> <p>JSON:</p> <pre><code> { "Code":0, "Status":"Done", "Categories":[ { "ID":1, "Name":"Eat", "Subcategories":[ {"Flag":false,"ID":100,"Name":"Food"}, {"Flag":false,"ID":101,"Name":"Fast Food"}, {"Flag":false,"ID":102,"Name":"Other"} ] }, { "ID":2, "Name":"Entertainment", "Subcategories":[ {"Flag":false,"ID":100,"Name":"All"}, {"Flag":false,"ID":101,"Name":"Movie"}, {"Flag":false,"ID":102,"Name":"Bowling"} ] }, } ] } </code></pre> <p>Entity:</p> <pre><code> public class MyData { public int Code { get; set; } public string Status { get; set; } public List&lt;Category&gt; Categories { get; set; } } public class Category { public string Name { get; set; } public int ID { get; set; } public List&lt;Subcategory&gt; Subcategories { get; set; } } public class Subcategory { public string Name { get; set; } public int ID { get; set; } public bool Flag { get; set; } } </code></pre> <p>ServiceCall:</p> <pre><code> public MyData GetAllCategories() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://host/data/categories/"); request.ContentType = "application/json; charset=utf-8"; request.Method = "GET"; string returnJson = string.Empty; using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream)) { while (!reader.EndOfStream) { returnJson += reader.ReadLine(); } } } } MyData deserializedMyData = JsonConvert.DeserializeObject&lt;MyData&gt;returnJson return deserializedMyData; } </code></pre>
    singulars
    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.
    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