日期:2014-05-17  浏览次数:20528 次

怎么让mvc3下拉框选项的selectListItem不能被选中 不能点击该项
<td width="31%" bgcolor="#ffffff" align="left">
  &nbsp;&nbsp; <span class="style19">
   
这是mvc3的下拉框 我怎么让从数据库读出来的值 有的项不点击啊 就是不能被选中.. 高手教教..mvc3的新手  

  @{
  List<SelectListItem> lst = new List<SelectListItem>();

  foreach (var md in ViewBag.ModelAdministration)
  {
  lst.Add(new SelectListItem { Text =md.Text, Value =md.Value });

  }
  }
  @Html.DropDownListFor(model => model.CalculationModel, lst, new { width = "200" })
  @Html.ValidationMessageFor(model => model.CalculationModel)
  </span>
  </td>

------解决方案--------------------
for (int i = 0; i < 10; i++)
{
ListItem item = new ListItem();
item.Text = i.ToString();
item.Value = i.ToString();
if (i % 2 == 0)
{
item.Attributes.Add("disabled", "disabled");
}
ddlProvinceList.Items.Add(item);
}
思路是给你了,至于你怎么用,那得你自己思考下了