public ActionResult MasterDropTable() { DataTable dt = new DataTable(); AllMail.MasterList(dt); List <DSRCManagementSystem.Models.MasterList.masterdroplist> objmodel = new List <Models.MasterList.masterdroplist>(); for (int i = 0; i < dt.Rows.Count; i++) { DSRCManagementSystem.Models.MasterList.masterdroplist obj = new DSRCManagementSystem.Models.MasterList.masterdroplist(); obj.Name = dt.Rows[i]["name"].ToString(); objmodel.Add(obj); } SelectList list = new SelectList(objmodel, "name", "name"); ViewBag.MasterTable = list; TempData["message"] = "Addeds"; return(View()); }
public ActionResult MasterDropTable(DSRCManagementSystem.Models.MasterList Name) { if (Name._drpMasterName == null) { DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); var selectedTable = Name._drpMasterName; Session["selectmasterTableName"] = selectedTable; Session["masterTableName"] = Name._drpMasterName; var selectMaster = db.Sp_Master(selectedTable).ToList(); var ColumnName = db.Sp_GetColumn(selectedTable).ToList(); var columndatatype = db.Sp_MasterDataType(selectedTable).ToList(); Name.ColumnNames = new List <Addmasterjoin>(); Name.ColumnDataTypes = new List <Addmasterjoin>(); ViewBag.columndatatype = columndatatype; ViewBag.ColumnName = ColumnName; for (int i = 0; i <= columndatatype.Count - 1; i++) { cs.ColumnDataType.Add(columndatatype[i]); Name.ColumnDataTypes.Add(new Addmasterjoin(columndatatype[i])); } for (int s = 0; s <= ColumnName.Count - 1; s++) { cs.ColumnName0.Add(ColumnName[s]); Name.ColumnNames.Add(new Addmasterjoin(ColumnName[s])); } Name._masterjoin = new List <masterjoin>(); foreach (var s in selectMaster) { var rs = s.Split('^').ToArray(); cs.id.Add(rs[0]); cs.value.Add(rs[1]); Name._masterjoin.Add(new masterjoin(rs[0].ToString(), rs[1].ToString())); } DataTable dt = new DataTable(); AllMail.MasterList(dt); List <DSRCManagementSystem.Models.MasterList.masterdroplist> objmodel = new List <Models.MasterList.masterdroplist>(); for (int i = 0; i < dt.Rows.Count; i++) { DSRCManagementSystem.Models.MasterList.masterdroplist obj = new DSRCManagementSystem.Models.MasterList.masterdroplist(); obj.Name = dt.Rows[i]["name"].ToString(); objmodel.Add(obj); } SelectList list = new SelectList(objmodel, "name", "name"); ViewBag.MasterTable = list; TempData["message"] = "Added"; // return View("<script language='javascript' type='text/javascript'>alert('Select MasterTableName ');</script>"); // return Content("<script language='javascript' type='text/javascript'>alert('Select MasterTableName ');</script>"); return(View()); } else { DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); var selectedTable = Name._drpMasterName; Session["selectmasterTableName"] = selectedTable; Session["masterTableName"] = Name._drpMasterName; var selectMaster = db.Sp_Master(selectedTable).ToList(); var ColumnName = db.Sp_GetColumn(selectedTable).ToList(); var columndatatype = db.Sp_MasterDataType(selectedTable).ToList(); Name.ColumnNames = new List <Addmasterjoin>(); Name.ColumnDataTypes = new List <Addmasterjoin>(); ViewBag.columndatatype = columndatatype; ViewBag.ColumnName = ColumnName; for (int i = 0; i <= columndatatype.Count - 1; i++) { cs.ColumnDataType.Add(columndatatype[i]); Name.ColumnDataTypes.Add(new Addmasterjoin(columndatatype[i])); } for (int s = 0; s <= ColumnName.Count - 1; s++) { cs.ColumnName0.Add(ColumnName[s]); Name.ColumnNames.Add(new Addmasterjoin(ColumnName[s])); } Name._masterjoin = new List <masterjoin>(); foreach (var s in selectMaster) { var rs = s.Split('^').ToArray(); cs.id.Add(rs[0]); cs.value.Add(rs[1]); Name._masterjoin.Add(new masterjoin(rs[0].ToString(), rs[1].ToString())); } DataTable dt = new DataTable(); AllMail.MasterList(dt); List <DSRCManagementSystem.Models.MasterList.masterdroplist> objmodel = new List <Models.MasterList.masterdroplist>(); for (int i = 0; i < dt.Rows.Count; i++) { DSRCManagementSystem.Models.MasterList.masterdroplist obj = new DSRCManagementSystem.Models.MasterList.masterdroplist(); obj.Name = dt.Rows[i]["name"].ToString(); objmodel.Add(obj); } SelectList list = new SelectList(objmodel, "name", "name"); ViewBag.MasterTable = list; return(View(Name)); } }