Advertisements

You should write
Me.dgReport.Tables(0).Columns(7).Visible = False
Then it will work fine.

Sunil TG

>-----Original Message-----
>I populate a datagrid by setting the datasource to a
>datatable. I then, bind them. After that I try to hide
the
>last column but am not able to. I get an error message.
>
>Here is my code:
>
> Me.dgReport.DataSource = ds.Tables("tFirst")
> Me.dgReport.DataBind()
> Me.dgReport.Columns(7).Visible = False
>
>Here is the error that I get:
>
>System.ArgumentOutOfRangeException: Index was out of
>range. Must be non-negative and less than the size of the
>collection. Parameter name: index
>
>
>If I take the last line of code out then the page
>displayes as expected except for the last column. I tried
>to hide column 3 but got the same result.
>
>After the Bind command I looked at the Columns.Count
>property and it is 0. Why is this happening and how do I
>fix it?
>
>Thanks
>enak
>
>.
>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!