imran bhatti

imran bhatti

  • NA
  • 28
  • 5.4k

mvc getting an error on converting ADT_DIST_CODE

Dec 22 2016 3:05 AM
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
RTC_PRINT_XMLEntities db = new RTC_PRINT_XMLEntities();
ViewBag.District = new SelectList(db.RTC_XML_ADT, "ADT_DIST_CODE", "ADP_DIST_NAME");
return View();
}
public JsonResult GetTalukById(string ID)
{
List<SelectListItem> taluk = new List<SelectListItem>();
var talukList = this.Gettaluk(Convert.ToInt32(ID));
var talukData = talukList.Select(m => new SelectListItem()
{
Text = m.ADT_TALUK_NAME,
Value = m.ADT_TALUK_CODE.ToString(),
});
return Json(talukData, JsonRequestBehavior.AllowGet);
}
public IList<RTC_XML_ADT> Gettaluk(int ADT_DIST_CODE_ID)
{
RTC_PRINT_XMLEntities db = new RTC_PRINT_XMLEntities();
return db.RTC_XML_ADT.Where(m => m.ADT_DIST_CODE == ADT_DIST_CODE_ID).ToList();
}
[HttpPost]
public ActionResult Index(FormCollection formdata)
{
// Get Employee information to insert into Data Base
return RedirectToAction("Index", "Home");
}
}
}
 
 
i am getting error on this line
RTC_PRINT_XMLEntities db = new RTC_PRINT_XMLEntities();
return db.RTC_XML_ADT.Where(m => m.ADT_DIST_CODE == ADT_DIST_CODE_ID).ToList();
 
ADT_DIST_CODE it is howing as a string.
ADT_DIST_CODE_ID it is as int bcoz i put integer there in parameter
how to solve this problem. 
 
 

Answers (10)