Hi, first save the appropriate values in the table
Template Field. after that took that id and pass it to the Table
OptionFieldValues.
Here i will post one example, In the below code first I insert the address details of student in the table
Address, after that store that
AddressID in the
Student Table using
SaveChanges()
public ActionResult Create(Member m)
{
if (ModelState.IsValid)
{
var address = new Address()
{
Address1 = m.Address.Address1,
Address2 = m.Address.Address2,
City=m.Address.City,
StateProvinceID=1,
CountryID=1,
PostalCode=m.Address.PostalCode,
ContactNo=m.Address.ContactNo
};
objMoneyManager.Addresses.Add(address);
objMoneyManager.SaveChanges();
int id = address.ID;
var member = new Member()
{
Name = m.Name,
MasterGroupID = m.MasterGroupID,
SubGroupID = m.SubGroupID,
RoleID = m.RoleID,
Status = m.Status,
AddressID=id
};
objMoneyManager.Members.Add(member);
objMoneyManager.SaveChanges();
return RedirectToAction("Index");
}
return RedirectToAction("Create");
}