i am using gridview. and i have a checkbox as a template column in gridview . when i checked single record and press delete button, then record is successfully perform delete. but when i check multiple record and click the delete then it gives following error:
Parameter name: index
Server Error in '/' Application.
Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
CSS |
i am using below code to perform delete operation i am developing application in three-tire architecture.
protected void btnDelete_Click(object sender, EventArgs e)
{
foreach (GridViewRow objData in gvEmployee.Rows)
{
CheckBox chkBox = (CheckBox)objData.FindControl("chkDelete");
if (chkBox.Checked)
{
int id = Convert.ToInt32(gvEmployee.DataKeys[objData.RowIndex].Value.ToString());
objB.Delete(id);
fillEmployeeDetail();
}
}
}
can anyone give me solution. with code in asp.net,C#

Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Oct 8, 2008, 6:25 AM EDT
HI
Not
sure why are you calling Fillemployeedetail for each and every record. If you have multiple updates/deletes then call this method at the end of request.now comming back
to the problem check out the below code, this is working at my end so replace the names with your object names.Thanks
-- Vjhttp
://dotnetvj.blogspot.comhttp
://oravj.blogspot.comjignesh kadvani51 reputationPosted Oct 9, 2008, 9:31 PM EDT
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Oct 10, 2008, 8:46 AM EDT
I am glad that the solution is working.
Thanks
-- Vjhttp
://dotnetvj.blogspot.comhttp
://oravj.blogspot.com