日期:2014-05-17 浏览次数:20428 次
<YearTable>
<yearNumber>2005</yearNumber>
<yearNumber>2006</yearNumber>
</YearTable>
public SelectList LoadYearDataFromXml
{
get
{
try
{
DataSet ds = new DataSet();
ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/xmlData_Years.xml"));
DataTable dt = ds.Tables[0];
EnumerableRowCollection<DataRow> rows = dt.AsEnumerable();
List<DataRow> _item = rows.ToList<DataRow>();
return new SelectList(_item);
}
catch
{
return null;
}
}
}
// GET: /System_MonthMaxMoneySetting/Create
public ActionResult Create()
{
System_MonthMaxMoneySetting mmms = new System_MonthMaxMoneySetting();
ViewBag.Items = mmms.LoadYearDataFromXml;
return View();
}
<div class="editor-field">
@Html.DropDownListFor(model => model.IYear,ViewBag.Items as SelectList)
@Html.ValidationMessageFor(model => model.IYear)
&n