Export selected rows of gridview to Excel or word in ASP.Net By Using 3-Tier Architecture

Posted by Priyatham under .NET Certifications on 7/2/2013 | Points: 10 | Views : 1512 | Status : [Member] | Replies : 0
private void SaveCheckedValues()
{
ArrayList userdetails = new ArrayList();
int index = -1;
foreach (GridViewRow gvrow in gvdetails.Rows)
{
index = (int)gvdetails.DataKeys[gvrow.RowIndex].Value;
bool result = ((CheckBox)gvrow.FindControl("chkSelect")).Checked;
// Check in the Session
if (ViewState["CHECKED_ITEMS"] != null)
userdetails = (ArrayList)ViewState["CHECKED_ITEMS"];
if (result)
{
if (!userdetails.Contains(index))
userdetails.Add(index);
}
else
userdetails.Remove(index);
}
if (userdetails != null && userdetails.Count > 0)
ViewState["CHECKED_ITEMS"] = userdetails;
}
Can any one help me out of this excepiton from the above code
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

M.priyatham


Responses

(No response found.)

Login to post response