// GET: Customer public ActionResult Index() { DataSet dataSetState = customer.GetStates(); ViewBag.statename = dataSetState.Tables[0]; List <SelectListItem> getstatename = new List <SelectListItem>(); foreach (System.Data.DataRow dr in ViewBag.statename.Rows) { getstatename.Add(new SelectListItem { Text = @dr["state_name"].ToString(), Value = @dr["state_id"].ToString() }); ViewBag.state = getstatename; } DataSet genderdataset = customer.GetGender(); ViewBag.gendername = genderdataset.Tables[0]; List <SelectListItem> getgendername = new List <SelectListItem>(); foreach (System.Data.DataRow dr in ViewBag.gendername.Rows) { getgendername.Add(new SelectListItem { Text = @dr["gender_"].ToString(), Value = @dr["gender_id"].ToString() }); ViewBag.gender_ = getgendername; } return(View()); }