。net MVC应用程序中如何在一个提交按钮下保存两个从表单获取值的学生对象?

问题描述 投票:0回答:1

这里是代码,并且控制器代码也在这里This is the Model of Entity Relationship

sql asp.net-mvc database sql-server-2005
1个回答
0
投票

<form action="Submit" method="post">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th colspan="4">Part A  :  Student Information</>
</tr>
</thead>
<tbody>
<tr>
<th width="2">Reg No:</th>
<td><input class="form-control" type="text" name="Registration_No" size="30" /></td>
<th width="2">Reg No:</th>
<td><input class="form-control" type="text" name="Registration_No1" size="30" /></td>
</tr>
<tr>
<th>Name</th>
<td><input class="form-control" type="text" name="Name" size="30" /></td>
</tr>
<tr>
<th>Phone</th>
<td><input class="form-control" type="text" name="Phone" size="30" /></td>
</tr>
<tr>
<th>Email</th>
<th><input class="form-control" type="text" name="Email" size="30" /></th>
</tr>
<tr>
<th>
<button class="btn btn-info form-control" name="Submit" value="Submit">Submit</button>
</th>
</tr>
</tbody>
</table>
</form>
 public JsonResult Submit(Student_Information stu)
    {


        db.Student_Information.Add(stu);



        db.Student_Information.Add(stu);
        db.SaveChanges();

}

© www.soinside.com 2019 - 2024. All rights reserved.