Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:26:28+00:00 2026-06-01T08:26:28+00:00

Following is my code with the business logic. I get below json by calling

  • 0

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.

As per my below code the dropdown should have “Eat” & “Entertainment” options. And if the user select “Entertainment” then it should display “All”, “Movie, & “Bowling” as the checkbox list. Can anyone please help me how to have this in MVC3 & C#?

JSON:

  {
  "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"}
                      ]
                     },
                     }
          ]
    }

Entity:

 public class MyData
 {
   public int Code { get; set; }
   public string Status { get; set; }
   public List<Category> Categories { get; set; }
  }

  public class Category
  {
      public string Name { get; set; }
      public int ID { get; set; }
      public List<Subcategory> Subcategories { get; set; }
  }

   public class Subcategory
   {
     public string Name { get; set; }
     public int ID { get; set; }
     public bool Flag { get; set; }
   }

ServiceCall:

    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<MyData>returnJson 


            return deserializedMyData;
      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:26:29+00:00Added an answer on June 1, 2026 at 8:26 am

    Use the following code in view
    @model MyData

     @foreach (Category item in Model.Categories)
            {
    <input type="checkbox" name="Categories" value="@item.categoryId" id="@item.categoryId"/>
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code illustrates an object literal being assigned, but with no semicolon afterwards:
How come in the following code my update business function always updates the input
I am working on two projects: A Business Logic Layer that is a class
Following code, when compiled and run with g++, prints '1' twice, whereas I expect
Following code iterates through many data-rows, calcs some score per row and then sorts
following code doesn't work with input: 2 7 add Elly 0888424242 add Elly 0883666666
Following code is from a sample of playframework-2.0: /** * Display the dashboard. */
Following code is to save image took from camera into photo album. if ([mediaType
The following code works great in IE, but not in FF or Safari. I
The following code doesn't compile with gcc, but does with Visual Studio: template <typename

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.