473,388 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Can't hide column in datagrid

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

Nov 17 '05 #1
1 2704
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 thelast 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

.

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: CBuck | last post by:
Hi, I was wondering if it was possible to hide the first column of the datagrid (windows form control). The column that I am referring to is the column created by the control that is gray in color...
6
by: Das | last post by:
Hi everyone, I'm using datagrid control to display the data. I want to hide column to be displayed into the data grid. I'm using the code as given below: Method given below is used to bind the...
8
by: Hanson | last post by:
I have a datagrid control in an aspx page. The datagrid columns will be dynamically generated according to the pre-page's search condition, I want to hide some columns in the datagrid. is that...
3
by: sivaraman.S | last post by:
Hi friends, How to hide a column in datagrid. regards, Sivaraman.S
5
by: J | last post by:
Ok, they have changed a lot of stuff in VB.net. How in the world do you hide a column on the Datagrid? -- Jason
2
by: Keithb | last post by:
I need to hide a GridView's "edit" column if the user's role does not support editing. However, the column's Visible property does not support databinding. Is there a workaround? Thanks, ...
1
by: nuhura01 | last post by:
Hi all.. I have a datagrid in my system and I preview the datagrid in other html page. Below are the code that I'm using: Dim oStringWriter As System.IO.StringWriter = New...
1
by: TonyJ | last post by:
Hello! Assume I have a datasource consisting of a database table. This table has 5 column. If I now want to use a bound datagrid but want to display only 4 of these 5 columns is that...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.