forum

Home / DeveloperSection / Forums / DropdownList issue in mvc?

DropdownList issue in mvc?

Anonymous User189509-Oct-2014
I am having a dropdownlist in my appliaction which I have binded through the database records but on any of the edit form I want to set the selected index of the dropdown list how shall I do that ,I am Postng my code here.

public IList GetFeedbackList()
        {
          int feedbackId = 0;
          string feedbackName = string.Empty;
 
          using (var db = new brandconnectionsEntities())
          {
            return (IList )(from s in db.BC_FeedbackBy
                              selectnew
                              {
 
                                 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"] asSelectList, "--Select--", new { @class = "inputtext1" })%>

Please tell how shall I set the selected index from database.


Updated on 09-Oct-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By