मेरे पास एक साइट है जो एएसपी.NET एमवीसी बीटा 5 का उपयोग कर रही थी, और मैंने इसे अभी एएसपी.NET एमवीसी 1.0 में अपग्रेड कर दिया है। मुझे एक ड्रॉप डाउन सूची में चयनित आइटम में परेशानी हो रही है।एएसपी.Net एचटीएमएल। ड्राडाडाउनलिस्ट चयनित तत्व चयनित नहीं
पालन व्यक्ति एक समान प्रश्न (Html.DropDownList in ASP.NET MVC RC (refresh) not pre-selecting item) है, लेकिन मैं कोई जवाब नहीं (अन्य की तुलना में यह एक बग हो सकता है)
मेरे नियंत्रक विधि इस प्रकार है लग रहा है:
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult View(Guid id)
{
IntegrationLogic logic = new IntegrationLogic(new IntegrationLinq());
CompanyLogic companyLogic = new CompanyLogic(new CompanyLinq());
IntegrationContainer container = new IntegrationContainer();
container.Sources = logic.GetImportSource(id);
container.Companies = companyLogic.GetCompanies(); // Returns a IList<company>
container.SourceActions = logic.GetAllSourceActions(); // Returns an IList<SourceAction>
container.SinkActions = logic.GetAllSinkActions();
container.SuccessActions = logic.GetAllSuccessActions();
container.FailureActions = logic.GetAllFailureActions();
container.Actions = logic.GetAllActions();
container.Watchers = logic.GetAllWatcherActions();
container.ChainActions = logic.GetAllChainActions();
return View("View", container);
}
दृश्य है एक जोरदार मॉडल के खिलाफ आपके द्वारा लिखा गया इस प्रकार
public partial class View : ViewPage<IntegrationContainer> {}
दृश्य टेम्पलेट में समस्या क्षेत्र है:
<label for="Companies">Company: </label><%=Html.DropDownList("Companies",
new SelectList(ViewData.Model.Companies, "id", "name", item.CompanyID))%>
मैं एक ड्रॉपडाउन सूची बना रहा हूं, चयनित आइटम वास्तव में कभी नहीं चुना जाता है - और यही समस्या है। "item.CompanyID" एक ग्रिड है, "आईडी" एक ग्रिड है और "नाम" IDD में प्रदान की गई कंपनी ऑब्जेक्ट पर एक स्ट्रिंग है जो ViewData.Model.Companies उदाहरण में आयोजित की जाती है।
यह वास्तव में एक बग है - मैं यह मुश्किल समझने के लिए क्यों यह अभी भी ASP.Net MVC में मौजूद है लगता है ... मैं पूरी तरह खुश हो सकता है अगर यह कुछ मैंने किया है है।
भले ही, सुझाए गए काम के आसपास क्या होगा?
धन्यवाद
SO पर 6 प्रश्नों के माध्यम से खोज करने के बाद, यह एकमात्र उत्तर है जो काम करता है ... धन्यवाद! – Martin
कोई समस्या नहीं है। :) – Kinlan
इस पर दीवार के खिलाफ मेरे सिर को टक्कर लगी, बहुत बहुत धन्यवाद। – aboy021