I have 2 tables in my database, one is for company and another is for Branch. When i crate a branch i must be select my company, so in that case i would like to take dropdown in my branch form. in dropdown i bind company id and company name from m_com(table)
foreach (var item in brnch)
{
Company company = new Company();
company.com_nam = item.com_nam;
company.com_id = item.com_id;
br.comModel.Add(company);
}
when i click on submit button com_id return with " , " eg: ",05 ". so in that case i get error of more then one variable exception.
public ActionResult Create(Branch model)
{
if (ModelState.IsValid)
{
var temp = Request.Form["com_id"].ToString();
string strNew = temp.Replace(" , ", " ");
m_br brpany = new m_br();
var br = erkDB.m_br.OrderByDescending(x => x.br_id).SingleOrDefault().br_id;