---
title: "DropdownList issue in mvc?"  
description: "DropdownList issue in mvc?"  
author: "Anonymous User"  
published: 2014-10-09  
updated: 2014-10-09  
canonical: https://www.mindstick.com/forum/2343/dropdownlist-issue-in-mvc  
category: "asp.net mvc"  
tags: ["ado.net", "asp.net mvc"]  
reading_time: 1 minute  

---

# DropdownList issue in mvc?

I am having a [dropdownlist](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework) in my appliaction which I have binded through the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) but on any of the edit [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) I want to set the selected [index](https://www.mindstick.com/blog/198/index-in-sql-server) of the [dropdown list](https://www.mindstick.com/forum/760/dropdown-list-open-hide-behind-another-dropdown-list-on-ie-7) how shall I do that ,I am Postng my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) here.\

```
public IList GetFeedbackList()        {          int feedbackId = 0;          string feedbackName = string.Empty;           using (var db = new brandconnectionsEntities())          {            return (IList )(from s in db.BC_FeedbackBy                              select new                              {                                  feedbackId =s.FeedbackById ,                                 feedbackName=s.FeedbackBy  ,                              })                          .ToList ();          }        }         //Code for returning the list         IList allfeedbacks = _dropdownProvider.GetFeedbackList();         ViewData["feedback_for"] = new SelectList(allfeedbacks, "feedbackId", "feedbackName");         //In the View Page        <%=Html.DropDownList("feedback_for", ViewData["feedback_for"] as SelectList, "--Select--", new { @class = "inputtext1" })%>
```

Please tell how shall I set the selected index from database.\

## Replies

### Reply by Anonymous User

ViewData["feedback_for"] = new SelectList(allfeedbacks, "feedbackId", "feedbackName", selectedvalue);

At least in MVC2.

I had a problem though wich disappeared when i gave the [dropdown](https://www.mindstick.com/articles/263/ajax-toolkit-dropdownextender-in-asp-dot-net) the same name as the key. Ie.

```
<%=Html.DropDownList("feedbackId", ViewData["feedback_for"] as SelectList, "--Select--", new { @class = "inputtext1" })%>
```


---

Original Source: https://www.mindstick.com/forum/2343/dropdownlist-issue-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
