احمد صدقی

احمد صدقی

  • NA
  • 106
  • 17.2k

More then one element exception

Mar 6 2019 5:54 AM
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;

Attachment: m_brController.zip

Answers (5)