IOT Virtual Conference - Register now to book your ticket and get updates
x
CONGRATULATIONS! C# Corner Q1, 2021 MVPs Announced
Why Join
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forumguidelines
Nivi sharma
1.7k
246
8.3k
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#?