Please Help..Urgetn Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Posted on 2005-04-26
I am having problems with my datagrid and I hope as always there is an Expert around to help me.
I have a dataGrid with a link buttons, when I click on the link button expecting to be redirected to another page, I get this error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "
I can't figure out what this error is and I hope there is an expert as always to help me on my project.
below is the section of code that is given me problems.
private void dataGrid_SelectedIndexChanged(object sender, System.EventArgs e)
//fill the form with the details of the selected row
int index = dataGrid.SelectedIndex;
--error on this line-- string key = dataGrid.DataKeys[index].ToString();
dataView1.RowFilter = dataGrid.DataKeyField+ "='" + key + "'";
Response.Redirect("CallDetail.aspx?CallID=" + key );
}//end selectedIndex method