c# - Server Error in '/WebSite8' Application. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index -
description:
an exception occurred during execution of current web request. please review stack trace more information error , originated in code.
exception details:
system.argument out of range exception: index out of range. must non-negative , less size of collection. parameter name: index
code:
protected void imagebutton1_click (object sender, eventargs e) { imagebutton lnkbtn = sender imagebutton; gridviewrow gvrow = lnkbtn.namingcontainer gridviewrow; string filepath = gridview2.datakeys[gvrow.rowindex].value.tostring(); response.contenttype = "image/jpg"; response.addheader("content-disposition", "attachment;filename=\"" + filepath + "\""); response.transmitfile(server.mappath(filepath)); response.end(); }
it looks me facing issue @ point
string filepath = gridview2.datakeys[gvrow.rowindex].value.tostring();
when trying pull out value of datakey gvrow.rowindex having value greater element count.
try debug , see count of element , gvrow.rowindex setting up.
Comments
Post a Comment