Message=Index was out of range. Must be non-negative and le
edit the selected row in gridview and focus remain on selection
error : Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
private void btnEdit_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(grdShow.SelectedRows[0].Cells[0].Value.ToString());
object[,] ObjEditProductDetails = new object[,] { {"@ProductId",id},{ "@ProductName", txtProductName.Text }, { "@Manufacturer", txtManufactorer.Text }, { "Rate",txtRate.Text } };
DB.ExecuteNonQuery_SP("Sp_UpdateProductDetails",ObjEditProductDetails);
int RowIndex = 0;
if (grdShow.Rows.Count > 0)
{
RowIndex = grdShow.SelectedRows[0].Index;
}
ShowGridView();
grdShow.SelectedRows[RowIndex].Selected = true;
ClearControls();
}