1 public ActionResult Create() 2 { 3 var model = new DisasterInf(); 4 5 model.ID = 0; 6 7 var DisasterTypeList = EnumHelper.GetItemValueList<EnumHelp.DisasterType>(); 8 this.ViewBag.DisasterType = new SelectList(DisasterTypeList, 9 "Key", "Value", model.DisasterType); 10 ViewBag.DisasterTypeValue = model.DisasterType; 11 12 var DisasterScaleList = EnumHelper.GetItemValueList<EnumHelp.DisasterScale>(); 13 this.ViewBag.DisasterScale = new SelectList(DisasterScaleList, 14 "Key", "Value", model.DisasterScale); 15 ViewBag.DisasterScaleValue = model.DisasterScale; 16 17 return View("Add", model); 18 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using GMS.Framework.Utility; 6 7 namespace GMS.Mrs.Disaster.Contract.Model 8 { 9 public class EnumHelp 10 { 11 public enum DealStatus 12 { 13 [EnumTitle("[无]", IsDisplay = false)] 14 None = -1, 15 16 /// <summary> 17 /// 等待处理 18 /// </summary> 19 [EnumTitle("等待处理")] 20 WaitDeal = 0, 21 22 /// <summary> 23 /// 正在处理 24 /// </summary> 25 // [EnumTitle("正在处理")] 26 // Dealing = 1, 27 28 /// <summary> 29 /// 处理完毕 30 /// </summary> 31 [EnumTitle("处理完毕")] 32 End = 1, 33 } 34 public enum DisasterScale 35 { 36 [EnumTitle("所有记录")] 37 None = -1, 38 39 [EnumTitle("小型")] 40 min = 0, 41 42 [EnumTitle("中型")] 43 middle = 1, 44 45 [EnumTitle("大型")] 46 max = 2, 47 48 [EnumTitle("特大型")] 49 supermax = 3, 50 51 } 52 53 public enum DisasterType 54 { 55 [EnumTitle("所有记录")] 56 None = -1, 57 58 59 [EnumTitle("滑坡")] 60 a = 0, 61 62 [EnumTitle("泥石流")] 63 b = 1, 64 65 [EnumTitle("地面崩塌")] 66 c = 2, 67 68 [EnumTitle("地裂")] 69 d = 3, 70 71 [EnumTitle("地面沉降")] 72 e = 4, 73 74 [EnumTitle("洪水")] 75 f = 5, 76 } 77 } 78 }
1 <div class="control-group"> 2 <label class="control-label"><span class="required">*</span>地灾类型:</label> 3 <div class="controls"> 4 @Html.DropDownList("DisasterType", ViewBag.DisasterType as SelectList, new { @class = "m-wrap medium" }) 5 <span class="help-inline">@Html.ValidationMessageFor(m => m.DisasterType)</span> 6 </div> 7 </div> 8 9 <div class="control-group"> 10 <label class="control-label"><span class="required">*</span>地灾规模:</label> 11 <div class="controls"> 12 @Html.DropDownList("DisasterScale", ViewBag.DisasterScale as SelectList, new { @class = "m-wrap medium" }) 13 <span class="help-inline">@Html.ValidationMessageFor(m => m.DisasterScale)</span> 14 </div> 15 </div>