2013-08-06 30 views
1

Hi我正在从数据库中检索Name的下拉列表。现在我想在DropDown页面中显示选定的值。我的代码如下检索数据,我使用Fluent数据作为框架。在页面中显示从DropDown中选择的值

我的控制器动作是

var query = Abc.GetProducts(); 

ViewBag.EnterpriseId = new SelectList(query.AsEnumerable(), "EnterpriseId", "Name"); 
return View(); 

我的看法是, @ Html.DropDownList( “EnterpriseID”,(的SelectList)ViewBag.EnterpriseID “ - 选择Resource--”)

+0

那是什么语言?请添加相应的标签。 – assylias

回答

0

你可以用这个简单的js:

elem = $('.selectClass'); 
options = elem.find('option[value="'+DataFromDBHere+'"]'); 
if(options){ 
options.prop('selected', 'selected'); 
} 
+0

先生,我已经尝试过它的nt workng – King

相关问题