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
Ashwanikumar singh
NA
39
48.5k
ASP.net Gridview operation using Entity Framework
Jun 3 2016 6:53 AM
I am performing Crud operation in asp.net using Entity framework
Everything thing is working fine but when i am updating the rows, it showing me null reference exception .
protected void datagrid1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = datagrid1.Rows[e.RowIndex];
int customerId = (int)(datagrid1.DataKeys[e.RowIndex].Value);
string firstname = (row.FindControl("txtFirstName") as TextBox).Text
; //h
ere i am getting exception
, nullreference exception
string lastname = (row.FindControl("txtLastName") as TextBox).Text;
int age = Convert.ToInt32(row.FindControl("txtAge") as TextBox);
using (NORTHWNDEntities entities = new NORTHWNDEntities())
{
studentDetail customer = (from c in entities.studentDetails
where c.Id == customerId
select c).FirstOrDefault();
customer.FirstName =firstname;
customer.LastName= lastname;
customer.Age = age;
entities.SaveChanges();
}
datagrid1.EditIndex = -1;
GetStudent();
}
Any help or suggestion would be much appreciated
Reply
Answers (
3
)
how to run function
How to print html div or table from user control in asp.net