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
Nilesh Avhad
NA
600
306.3k
Error while deleting record from gridview
Apr 14 2013 12:58 AM
I have gridview like as follows in asp.net 2010.
When I press delete button of gridview I am getting a error like this
Error : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
The code written on that button as follows.
protected void gvBrdDetail_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
int BoardID = Convert.ToInt32(gvBrdDetail.DataKeys[e.RowIndex].Values["ID"].ToString());
// string NationalityName=gvNatDetail.DataKeys[e.RowIndex].Values["NatNam"].ToString();
SqlCommand cmd = new SqlCommand("delete from TbBrdMst where ID=" + BoardID, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
FillGrid();
lblSuccess.Text = "Message : Record deleted successfully with Board ID= " + BoardID;
}
catch (Exception ex)
{
lblError.Text = "Error : " + ex.Message;
con.Close();
return;
}
}
Reply
Answers (
2
)
How to deploy web servce on local machine?
How to import excel data with formulae into datagridview