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
Guest User
Tech Writer
271
36.2k
Update data in Codefirst approach in asp.net entity framework
Sep 17 2020 2:51 AM
Hello Experts..
my scenario is update data in Code First approach in asp.net EF and I am using gridview to do CRUD operation..... I am stuck in Update operation...
I am using this scenario....
protected
void
GridView1_RowUpdating(
object
sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
TextBox txtName = row.FindControl(
"txtName"
)
as
TextBox;
TextBox txtDesignation = row.FindControl(
"txtDesignation"
)
as
TextBox;
using
(DatabaseContext context =
new
DatabaseContext())
{
int
Id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
Designation obj = context.Designations.First(x => x.Id == Id);
obj.Name = txtName.Text;
obj.Designationn = txtDesignation.Text;
db.Entry(modal).State = EntityState.Modified;
context.SaveChanges();
bindGridview();
}
}
Reply
Answers (
3
)
What is the code that will produce this MIPS result?
how to encrypt string using AES 128 bit in c#?