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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:26:53+00:00 2026-06-03T18:26:53+00:00

I am using MVC3. I’m binding the dropdown with the Data coming from a

  • 0

I am using MVC3. I’m binding the dropdown with the Data coming from a service. But after the page posts back and a filter applies to list, the dropdown shows the filter record value in the grid because I always bind the list coming from the service.

However, I want the dropdown to always show all the Records in the database.

  • 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-03T18:26:55+00:00Added an answer on June 3, 2026 at 6:26 pm

    I don’t understand your question that clearly. But it seems that it is a dropdown that you have on your view? I also have no idea what you are trying to bind so I created my own, but have a look at my code and modify it to fit in with your scenario.

    In your view:

    @model YourProject.ViewModels.YourViewModel
    

    On the view there is a list of banks in a dropdown list.

    Your banks dropdown:

    <td><b>Bank:</b></td>
    <td>
         @Html.DropDownListFor(
              x => x.BankId,
              new SelectList(Model.Banks, "Id", "Name", Model.BankId),
              "-- Select --"
         )
         @Html.ValidationMessageFor(x => x.BankId)
    </td>
    

    Your view model that will be returned to the view:

    public class YourViewModel
    {
         // Partial class
    
         public int BankId { get; set; }
         public IEnumerable<Bank> Banks { get; set; }
    }
    

    Your create action method:

    public ActionResult Create()
    {
         YourViewModel viewModel = new YourViewModel
         {
              // Get all the banks from the database
              Banks = bankService.FindAll().Where(x => x.IsActive)
         }
    
         // Return the view model to the view
         // Always use a view model for your data
         return View(viewModel);
    }
    
    [HttpPost]
    public ActionResult Create(YourViewModel viewModel)
    {
         if (!ModelState.IsValid)
         {
              // If there is an error, rebind the dropdown.
              // The item that was selected will still be there.
              viewModel.Banks = bankService.FindAll().Where(x => x.IsActive);
    
              return View(viewModel);
         }
    
         // If you browse the values of viewModel you will see that BankId will have the
         // value (unique identifier of bank) already set.  Now that you have this value
         // you can do with it whatever you like.
    }
    

    Your bank class:

    public class Bank
    {
         public int Id { get; set; }
         public string Name { get; set; }
         public bool IsActive { get; set; }
    }
    

    This is simple as it gets. I hope this helps 🙂

    PS: Please remember with future posts, always give as much detail as possible so that we can help you better. Also don’t forget to display code samples so that we can see what you have already done. The more details that we can have the better.

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

Sidebar

Related Questions

Using MVC3 and Entity Framework. Am trying to get validation flowing from data model
I'm using MVC3 with EF (version 4, but not sure if 4.0,4.1,etc). I've been
I am using MVC3, in which I have a page let say Home.cshtml with
I am using MVC3 and that i know MVC3 support binding JSON literal to
Using mvc3, is there some variable to inform if I came from a Create
im using MVC3. im trying to redirectToAction after doing a jquery post. edit: sorry
I am using MVC3 and am trying to serve content from https, the problem
I am using MVC3 webgrid. I am displaying the data in a webgrid and
I am using MVC3 Web Grid. I need to export the data into excel
I am using MVC3-ViewModel with EF model first on my project. and the view

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.