Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Source Error: Line 28: if (grdAvailableStuff.Columns.Count > 0) Line 29: { Line 30: grdAvailableStuff.Columns[2].Visible = false; Line 31: Line 32:
if (grdAvailableStuff.Columns.Count > 0) { grdAvailableStuff.Columns[2].Visible = false; } else { grdAvailableStuff.HeaderRow.Cells[2].Visible = false; foreach (GridViewRow grd in grdAvailableStuff.Rows) { grd.Cells[2].Visible = false; } }
protected void grdAvailableStuff_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[1].Visible = false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)