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
narasiman rao
NA
519
765.7k
Delete the partiuclar row in gridview in asp.net using c#
May 28 2015 11:32 PM
I am deleting partiuclar row in gridview.
Run mode as follows
Waitlistid Course Batchdate
1 AFF 25 Aug 2014
2 MFA 26 Sep 2015
3 ERS 20 Mar 2012
4 ROC 19 Jul 2012
My code as follows
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
DataTable dt = ViewState["dt"] as DataTable;
dt.Rows[index].Delete();
ViewState["dt"] = dt;
BindGrid();
}
protected void BindGrid()
{
GridView1.DataSource = ViewState["dt"] as DataTable;
GridView1.DataBind();
}
When i delete the 4th row in gridview in row mode shows error as follows
Object reference not set to an instance of an object.
The above error shows in below line as follows
dt.Rows[index].Delete();
please help me. what is the problem in my abvoe code.
Reply
Answers (
2
)
connection to database from access db
Problem Related Html Table Merge cell down(column wise)