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 7012115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:12:50+00:00 2026-05-27T22:12:50+00:00

I am using the following to generate a drop down list: @for (var index

  • 0

I am using the following to generate a drop down list:

@for (var index = 0; index < Model.AdminSummaries.Count(); index++) 
            { 
            <div class="rep_tr0"> 
                <div class="rep_td0"> 
                    @Html.DropDownListFor(x => Model.AdminSummaries[index].Status, 
                       AdminStatusReference.GetAdminStatusOptions(),
                       new { id = string.Format("Status_{0}",index ) })
                 </div> 
            </div>
            }

Here’s the HTML it generates:

<select id="Status_1" name="AdminSummaries[1].Status"><option value="1">Released</option>
<option value="2">Review</option>
<option value="3">New</option>
</select>

Here’s the class that gives the status options.

public static class AdminStatusReference
{

    public static IEnumerable<SelectListItem> GetAdminStatusOptions()
    {
        return new[]
            {
                new SelectListItem { Value = "1", Text = "Released"  },
                new SelectListItem { Value = "2", Text = "Review" },
                new SelectListItem { Value = "3", Text = "New" }
            };
    }

}

Everything works good EXCEPT it doesn’t select the items correctly. There’s no option with ‘selected’ to match the data in the AdminSummaries.

How can I make it so the correct select list items are selected?

Just to clarify this. My problem is that if there is a data record with a value of 3 for the status then when I look at the screen I see a select list with the word “Release” showing.

What I need is for the select list to show text that corresponds with the data value.

  • 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-27T22:12:51+00:00Added an answer on May 27, 2026 at 10:12 pm

    Here is the more accurate answer

    public static class AdminStatusReference 
    { 
        public static IEnumerable<SelectListItem> GetAdminStatusOptionsFor(AdminSummaries arg) 
        { 
            var options = new[] 
                { 
                    new SelectListItem { Value = "1", Text = "Released" }, 
                    new SelectListItem { Value = "2", Text = "Review" }, 
                    new SelectListItem { Value = "3", Text = "New" } 
                }; 
            options.First(o=> o.Value == arg).Selected = true;
            return options; 
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code to generate an encrypted token: var ticket =
I am using following code to generate a list box.. <%: Html.ListBoxFor(m => m.Subscribers,
I have a drop down list that is dynamically generated using a mySQL database
I'm using the following code to generate a list of all wordpress blogs in
I generate an excel file using XML format outlined on stackoverflow in the following
I am using following class to show a grid like appearance with pagination on
The scenario Suppose I have the following two model classes: public class ProductColor {
I'm currently using the following two command to generate client statements populated from mysql
I am currently using the following PHP code generate a Select Box with different
I was using the following in web.xml to configure a servlet to dynamically generate

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.