TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
احمد صدقی
NA
106
17.2k
I recieve my ID double while Editing the Dropdown
Mar 7 2019 3:21 AM
I create my Branch,where i choose Dropdown to select my Company, in dropdown i bind Company ID and Company Name.When i create my Edit function.I filled all my required fields,When I click on my Edit button,I found my com_id double, eg:04 is my real ID and I get "0404", now how can i resolve it?
Here is my Controller
public
ActionResult Edit(
string
id)
{
Branch model =
new
Branch();
var br = erkDB.m_br.FirstOrDefault(x => x.br_id == id);
model.br_id = id;
model.br_nam = br.br_nam;
model.br_add = br.br_add;
model.br_eml = br.br_eml;
model.br_fax = br.br_fax;
model.br_mob = br.br_mob;
model.br_typ = br.br_typ;
model.com_id = br.com_id;
var com = erkDB.m_com.ToList();
foreach
(var item
in
com)
{
Company company =
new
Company();
company.com_nam = item.com_nam;
company.com_id = item.com_id;
model.comModel.Add(company);
}
return
View(
"Create"
, model);
}
[HttpPost]
public
ActionResult Edit(Branch model)
{
if
(ModelState.IsValid)
{
var br = erkDB.m_br.FirstOrDefault(x => x.br_id == model.br_id);
var temp = Request.Form[
"com_id"
].ToString();
string
strNew = temp.Replace(
","
,
""
);
//br.br_id = br;
br.br_nam = model.br_nam;
br.br_pho = model.br_pho;
br.com_id = strNew;
br.br_web = model.br_web;
br.br_mob = model.br_mob;
br.br_eml = model.br_eml;
br.br_fax = model.br_fax;
br.br_typ = model.br_typ;
// mvcdb.m_com.Add(company);
erkDB.SaveChanges();
return
RedirectToAction(
"Index"
);
}
return
View(
"Create"
, model);
}
Reply
Answers (
2
)
EntityFramework.dll but was not handled in user code
Minify Angular Js