Hi
Try like this..
You are trying to access the index value of collection which is not available, so its better to check the index available before accessing.
int index = e.Item.DataItemIndex;
int length = ListView1.DataKeyNames.Length;
if( index < length)
Response.Redirect("~/ViewDetails.aspx?val=" + ListView1.DataKeyNames[index].ToString());