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

  • Home
  • SEARCH
  • 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 523033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:24:56+00:00 2026-05-13T08:24:56+00:00

I have a table with a Int PK column and a name. I want

  • 0

I have a table with a Int PK column and a name. I want to load them into an object of some sort and return them using Json() ActionResult in MVC 2. I am having a hard time finding a built-in structure that is supported for serialization that keeps a simple key/value structure in tact.

Ultimately I would like to do something like:

    Function JsonList() As ActionResult
        Dim Things = New Dictionary(Of Integer, String)

        Things.Add(0, "Choose One")
        For Each oThing In Edm.ThingsTable.ToList()
            Things.add(oThing.id, oThing.name)
        Next

        Return Json(Things, JsonRequestBehavior.AllowGet)
    End Function

and get something like:

{'2':'thing','12':'another thing','929':'yet another thing'}

I am using jQuery Jeditable which idealy would want something like:

{'2':'thing','12':'another thing','929':'yet another thing', 'selected':'129'}

It would great if there was a Json object that I could use like

oJson.add("bla", "foo")

But I have not discovered any structures that can do this.

  • 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-05-13T08:24:56+00:00Added an answer on May 13, 2026 at 8:24 am

    Your current code is almost exactly right. Just intead of a dictionary of int,string you need one of string,string:

    Function JsonList() As ActionResult 
        Dim Things = New Dictionary(Of String, String) 
    
        Things.Add("0", "Choose One") 
        For Each oThing In Edm.ThingsTable.ToList() 
            Things.add(oThing.id.ToString, oThing.name) 
        Next 
    
        Return Json(Things, JsonRequestBehavior.AllowGet) 
    End Function 
    

    And this will generated JSON like {"0":"Choose One","1":"Choose Two","2":"Choose Three"}.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Name column in employee table . I want to see all
I have table in data base name train delay, with columns train number(int), DelayTime(int),
Assume I have a table like this: column A(int) column B(int) 1 2 2
I have this table: ID(INT) DATE(DATETIME) Under the DATE column there are a lot
Say I have an MSSQL table with two columns: an int ID column that's
I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar)
Hi I want to have two tables each have an INT id column which
I have a table structure like the following: table a: id int name varchar
I have table Cars Id nvarchar(25) PK Name nvarchar(max) And there is some records.
I have one table with name CateringPurchaseOrder. That table contains one column with name

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.