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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:49:03+00:00 2026-06-02T07:49:03+00:00

In Edit view: I am passing ViewBag list for the ddl Controller: ViewBag.CountryList =

  • 0

In Edit view:
I am passing ViewBag list for the ddl

Controller:

 ViewBag.CountryList = new SelectList(db.Country, "CountryCode", "Desc");  

in edit view:
How do I assign the viewbag to the ddl and set the value that is coming from the model

@Html.EditorFor(model => model.CountryCode) <- contains the Desc Value, currently just shows in a textbox!

thx!

  • 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-02T07:49:04+00:00Added an answer on June 2, 2026 at 7:49 am

    use @Html.DropDownListFor. If you read the parameters that C# specifies you need, its self explanitory. The fact you have the selectList in the viewbag already means you’ve nearly done it all yourself already.

     @Html.DropDownListFor(model => model.CountryCode, ViewBag.CountryList);
    

    If that doesnt set the correct value for any reason, you can also use

     @Html.DropDownList("CountryCode", ViewBag.CountryList, new { @value = @Model.CountryCode });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i have a Parents controller with list and edit view for it (to
EDIT: It is not a listbox. My mistake. It is a list view. I
I have a problem in passing a value from controller to view In controller,
I'm passing an XElement to my Edit view and want to have the usual
I'm creating a view based on a list, intending to allow users to edit
I have a list of categories and sub categories which is passing from controller
I have a edit View - Product/Edit/1 1 being the Id of the Product.How
There's a setting on the Edit View page in SharePoint 2010 that allows you
I am working with an edit user view that includes First name, Last Name,
Is there a way to change the default pages used to edit/create/view a Sharepoint

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.