public string get_MainFunctionList() { mainfunctionDB = new MainFunctionDB(); DataTable dt = mainfunctionDB.getData(); List <SelectListItem> mySelectItemList = new List <SelectListItem>(); try { foreach (DataRow dr in dt.Rows) { mySelectItemList.Add(new SelectListItem() { Text = dr["MainFunctionName"].ToString(), Value = dr["MainFunctionID"].ToString(), Selected = false }); } _MainFunctionList = mySelectItemList; } catch (Exception ex) { return(ex.StackTrace.ToString()); } return(null); }
/// <summary> /// 取得主功能清單 /// </summary> public void getMainFunctionList() { MainFunctionDB mainfunctionDB = new MainFunctionDB(); DataTable MainFunctionDT = new DataTable(); MainFunctionDT = mainfunctionDB.getData(); foreach (DataRow dr in MainFunctionDT.Rows) { MainFunctionModel Data = new MainFunctionModel(); Data.MainFunctionID = Convert.ToInt32(dr["MainFunctionID"]); Data.MainFunctionName = dr["MainFunctionName"].ToString(); MainFunctionList.Add(Data); } }