You have AutoGenerateColumns property turned ON.

On Thu, Apr 2, 2009 at 10:41 PM, eddiec <[email protected]> wrote:

>
> Hi,
>
> I am trying to hide a column of  a gridview
>
> Code in C# is
> myDataGrid.Columns[0].Visible = false;
>
> When I run the code I receive an error:
> Exception Details: System.ArgumentOutOfRangeException: Index was out
> of range. Must be non-negative and less than the size of the
> collection.
> Parameter name: index
>
> I guess the probem is that where I am accessing the grid it hasn't
> been rendered yet.
>
> I have tried putting the code after data binding in the page load
> event and also in the RowDataBound event handler but receive the same
> error either way.
>
> Help!
>
> cheers
>
> eddiec :-)




-- 
Regards,
Rizwan Ahmed

Reply via email to