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
Senthil V
NA
8
401
Asp.net MVC - Reg.
Jul 12 2019 12:30 AM
Hi,
I want to know about how to pass textbox and HTML table values to the controller for saving in the database using entity framework... Please help me to do this. I am new to Asp.net MVC.
Jquery for passing HTML Table values
$(
'#_btnSubmit'
).on(
'click'
,
function
() {
var
listofsubjects =
new
Array();
alert(
'This is Inner html'
);
debugger
;
$(
'#tbodyGridBoard tbody tr'
).each(
function
() {
var
row = $(
this
);
var
listofsubject = {};
listofsubject.Subject_Name = row.find(
'td'
).eq(1).html();
listofsubject.Sub_MaxMarks = row.find(
'td'
).eq(2).html();
listofsubject.Sub_Scored = row.find(
'td'
).eq(3).html();
debugger
;
listofsubjects.push(listofsubject);
});
$.ajax({
type:
'POST'
,
url:
'Dropdown/Submit'
,
datatype:
'JSON'
,
contentType:
'application/json; charset=utf-8'
,
data: JSON.stringify(listofsubjects),
success:
function
(r) {
alert(
'Saved Successfully'
);
}
});
});
Controller :
int
Currentid = 0;
[HttpPost]
public
ActionResult Submit(StudentViewModel svm, FormCollection fc)
{
if
(ModelState.IsValid)
{
DatabaseDal dal =
new
DatabaseDal();
svm.studentDetails.postAppliedFor = fc[
"SelectedText"
].ToString();
dal.Studentdetails.Add(svm.studentDetails);
dal.SaveChanges();
Currentid = svm.studentDetails.Saveid;
svm.SaveSubjects.Save_ID = Currentid;
dal.SaveSubjectsList.Add(svm.SaveSubjects);
dal.SaveChanges();
}
return
View(
"ApplicationEnter"
, svm);
}
Highlighted text is used for saving html table values to another table.
Reply
Answers (
3
)
Deceptive site ahead how to fix the issue at programming lev
My table has two datepicker controls one dropdown and three