Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Can't hide column in datagrid

Reply
Thread Tools

Can't hide column in datagrid

 
 
enak
Guest
Posts: n/a
 
      10-31-2003
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

 
Reply With Quote
 
 
 
 
Sunil TG
Guest
Posts: n/a
 
      10-31-2003
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
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide a GridView column when the column's Visible property does not support databinding? Keithb ASP .Net 2 10-27-2006 05:02 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
How to hide a column in datagrid with AutoGenerateCol=true Thanh Nu ASP .Net 2 10-30-2003 03:12 PM
Trying to hide a datatable column from my datagrid... please help jonnylbluejeans ASP .Net 4 07-24-2003 09:52 PM



Advertisments