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
Ramco Ramco
443
3.4k
526.8k
Add Record when clicked Save in modal popup
Jun 3 2021 9:22 AM
Hi
Hi Sachin . How i can Add record in database with below code. I am using Ado.Net.
@model IEnumerable<MyApplication.Models.Location>
<button type=
"button"
class
=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#myModal"
onclick=
"clearTextBox();"
> <i
class
=
"fa fa-plus"
></i> Add New</button><br /><br />
<table table table-striped table-bordered
" style="
width:100%
" id="
tblLocation">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.IsActive)
</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (
var
item
in
Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsActive)
</td>
<td>
<a
class
=
'btn btn-primary btn-sm'
id=
'btnEdit'
><i
class
=
'fa fa-pencil'
></i> Edit </a>
@
if
(item.IsActive.ToUpper() ==
"N"
)
{
<a
class
=
'btn btn-danger btn-sm disabled'
id=
'btnDelete'
style=
'margin-left:5px'
><i
class
=
'fa fa-trash'
></i> Delete</a>
}
else
{
<a
class
=
'btn btn-danger btn-sm'
id=
'btnDelete'
style=
'margin-left:5px'
><i
class
=
'fa fa-trash'
></i> Delete</a>
}
</td>
</tr>
}
</tbody>
</table>
<script src=
"~/Scripts/Appjs/Location.js"
></script>
<div
class
=
"modal fade"
id=
"myModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
<div
class
=
"modal-dialog"
>
<div
class
=
"modal-content"
>
<div
class
=
"modal-header"
>
<button type=
"button"
class
=
"close"
data-dismiss=
"modal"
><span aria-hidden=
"true"
>×</span><span
class
=
"sr-only"
>Close</span></button>
<h4
class
=
"modal-title"
>Add New Location</h4>
</div>
<div
class
=
"modal-body"
>
<div
class
=
"form-horizontal"
>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-sm-3"
for
=
"Id"
>Id</label>
<div
class
=
"col-sm-2"
>
<input type=
"text"
class
=
"form-control form-control-sm"
id=
"txtId"
placeholder=
"Id"
>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-sm-3"
for
=
"Description"
>Description</label>
<div
class
=
"col-sm-9"
>
<input type=
"text"
class
=
"form-control form-control-sm"
id=
"txtDescription"
placeholder=
"Description"
>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-sm-3"
for
=
"IsActive"
>Active</label>
<div
class
=
"col-sm-2"
>
<input type=
"text"
class
=
"form-control form-control-sm"
id=
"txtIsActive"
placeholder=
"Active"
>
</div>
</div>
</div>
</div>
<div
class
=
"modal-footer"
>
<button type=
"button"
class
=
"btn btn-primary"
id=
"btnAdd"
onclick=
"return Add();"
>Save</button>
<button type=
"button"
class
=
"btn btn-primary"
id=
"btnUpdate"
style=
"display:none;"
onclick=
"Update();"
>Update</button>
<button type=
"button"
class
=
"btn btn-warning"
data-dismiss=
"modal"
>Cancel</button>
</div>
</div>
</div>
</div>
Thanks
Reply
Answers (
1
)
Given a DB context object named context that has a DbSet<Customer> pro
ReportViewer Control