public ActionResult Doctor() { if (Session["user"] != null) { if (Convert.ToString(Session["RoleID"]) == "2") { int ID = Convert.ToInt16(Session["ID"]); var data = clinic.Doctor(ID); List <SelectListItem> objitem = new List <SelectListItem>(); foreach (spDocDrop_Result item in data) { objitem.Add(new SelectListItem { Text = item.UserID + ", " + item.FirstName + " " + item.LastName, Value = item.UserID.ToString() }); } TempData["DropDownDoc"] = objitem; } else { var data1 = clinic.DocAppointment(2); List <SelectListItem> objitem1 = new List <SelectListItem>(); foreach (spDocDetails_Result item in data1) { objitem1.Add(new SelectListItem { Text = item.UserID + "," + item.FirstName + " " + item.LastName, Value = item.UserID.ToString() }); } TempData["DropDownDoc"] = objitem1; } } return(View()); }