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
neel k
NA
143
137k
insert record in mvc 5
May 22 2015 11:06 AM
Hi,
I have 3 tables
One table: tbl_applications
app_id
app_name
description
Second table: tbl_applicationGroups
ag_id
ag_name
ag_description
third table : tbl_AGApplications
ag_ID
app_id
I need to insert a record from UI into tbl_applications
in my UI form contains tbl_applications fields(textbox) and tbl_applicationGroups.ab_name(dropdown). I need to insert ag_id, app_id into tbl_AGApplications table.
[HttpGet]
public ActionResult Addapplication(int? appgroupid)
{
if (ModelState.IsValid)
{
var reportGroup = from w in db.SP_GR_Get_appGroupNames()
select w;
ViewBag.reportGroupNames = new SelectList(reportGroup, "RG_ID", "RG_Name", appgroupid);
}
return View();
}
[HttpPost]
public ActionResult Addapplications(
tbl_applications
reports applications,
tbl_applicationGroups application
groups)
{
ModelState.Clear();
if (ModelState.IsValid)
{
db.
tbl_applications
reports .Add(reports);
db.SaveChanges();
db.SP_GR_InsertapplicationGroupID(reportgroups.RG_ID, reports.Report_ID);
return RedirectToAction("AvailableReports");
}
return View(reports);
}
stored procedure
CREATE PROCEDURE SP_GR_InsertapplicationGroupID
@ReportGroupID int,
@ReportID int
AS
BEGIN
INSERT INTO
tbl_applications
reports
([dbo.tbl_GR_RGReports.RG_ID], [dbo.tbl_GR_RGReports.Report_ID])
VALUES (@ReportGroupID ,@ReportID )
END
Reply
Answers (
1
)
MVC 4.0
bind the repeater