So, I've been trying to create a record.however I created it successfully but the problem is that I may need the ID that has been auto incremented.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create([Bind(Exclude="CustomerServiceMappingID")] Maping serviceToCreate, FormCollection form)
{
if (!ModelState.IsValid)
return View();
var dc = new ServicesDataContext();
dc.Mapings.InsertOnSubmit(serviceToCreate);
try
{
dc.SubmitChanges();
}
catch (Exception e)
{
}
after this, I tried to do this which has not been working
var id = Int32.Parse(form["CustomerServiceMappingID"]);
var qw = (from m in dc.Mapings
where id == m.CustomerServiceMappingID
select m.CustomerID).First();
// var id = Int32.Parse(form["CustomerID"]);
return RedirectToAction("Index", new { id = qw });
Now I need to send Customer ID as a parameter to Index.. SO, can u help me out..
Thanks,
serviceToCreate.Idwill be set after you dodb.SubmitChanges(). Unless of course an error occured, which you'll never know because your swallowing it.