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);
}
{
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;
{
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;
Salman BegPosted Mar 6, 2019, 6:07 AM
احمد صدقیPosted Mar 6, 2019, 6:19 AM
Additional information: An error occurred while updating the entries. See the inner exception for details.
احمد صدقیPosted Mar 6, 2019, 6:10 AM
Salman Beg
can you please take my teamviewer?احمد صدقیPosted Mar 6, 2019, 6:05 AM
Muthu KumarPosted Mar 6, 2019, 6:03 AM
Please check below links,
https://stackoverflow.com/questions/15021257/invalidoperationexception-sequence-contains-more-than-one-element
https://stackoverflow.com/questions/22691622/sequence-contains-more-than-one-element-singleordefault-not-helping/22691701