public ActionResult EditIVRTemplate(int?id) { ViewBag.Gateway = new SelectList(Enumerable.Empty <SelectListItem>()); using (var con = new SqlConnection(_connectionString)) { var result = con.Query <IVRTemplate>("Select * from IVRTemplate where TemplateID=@id", new { id = id }, commandType: CommandType.Text).FirstOrDefault(); if (result != null) { if (result.MsgType == "E-Mail") { ViewBag.Gateway = new SelectList(dropdown.BindEmailGatewayEdit(), "Value", "Text"); } else if (result.MsgType == "SMS") { ViewBag.Gateway = new SelectList(dropdown.BindSMSGatewayEdit(), "Value", "Text"); } } return(PartialView(result)); } }