Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Delete the partiuclar row in gridview in asp.net using c#
narasiman rao
May 28 2015 11:32 PM
535
Reply
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
connection to database from access db
Problem Related Html Table Merge cell down(column wise)