473,378 Members | 1,577 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,378 software developers and data experts.

Problems with Columns in Datagrids

I have created a datagrid from a query, but when I display it it displays ALL the columns.

I want to hide some columns.

So I added this line
applicantsDataGrid.Columns[1].Visible = false;


But that gives me this error:
Inner Exception
----------------------------------------------

Message: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source: mscorlib
Stack Trace: at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.UI.WebControls.DataGridColumnCollection .get_Item(Int32 index)
at MySiteDB.UI.Applicants.Default.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()

It's as if there are no columns, but all the columns ARE displayed.

Can anyone let me know what I'm doing wrong here?

Many thanks
Richard
Mar 22 '07 #1
4 1032
When I create a datagrid, I always add AutoGenerateColumns="false" in the declaration.

<asp:Datagrid id="something" AutoGenerateColumns="false" runat="server" />

Then in the <columns> section I only specify the columns I want to display.

Hope this helps.
Mar 22 '07 #2
in asp.net

it datagrid proberty builder just u can uncheck the visible check box
Mar 22 '07 #3
When I create a datagrid, I always add AutoGenerateColumns="false" in the declaration.

<asp:Datagrid id="something" AutoGenerateColumns="false" runat="server" />

Then in the <columns> section I only specify the columns I want to display.

Hope this helps.

Great, I'll give this I try, it seems promising! (I guess I'll have to change the smily face though!)
Mar 23 '07 #4
Thanks I have it working now (simple really isn't it!)
Mar 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: TPSreport | last post by:
ASP.NET 2003. Two DataGrids, six columns each, one grid atop the other. I need to have the columns line up, i.e., DataGrid1 Col(1) lined up w/ DataGrid2 Col(1) - each the same width on the...
2
by: anon | last post by:
I am trting to simulate the case available in an excel worksheet where the first three columns are frozen and the rest scroll left and right against this. For example: I have a grid which lists...
3
by: Cyril Tiwari | last post by:
Could someone tell me how to add a button column to a datagrid, in a Windows Form? Here's where I'm at: ----------------------------------------------------------------------------...
0
by: Stephan Steiner | last post by:
Hi I have a network program that fills 4 datatables while receiving data bursts and which should then show those tables in 4 datagrids. The main GUI class contains event callbacks for events...
3
by: Csharper95 | last post by:
I'm working on a program that will display a modal form containing 2 datagrids (but might as well focus on just one for now). These datagrids display read-only information that is stored in arrays....
3
by: Lloyd Sheen | last post by:
I am having trouble with an app that does the following: 1. Query SQL Server and return one row 2. Bind the columns to text boxes 3. User updates info 4. User clicks update button ...
5
by: tshad | last post by:
I have been trying to figure out what the Datagrid is doing to create its formatting. I found that some of my Datagrids have a 3D type of border and sometime it has a straight line. I finally...
3
by: simchajoy2000 | last post by:
Hi, I have been working with datagrids a lot in the past two weeks and I am running across a lot of problems. Maybe there is no way around these problems but I hope there are and someone out...
0
by: mvisnich | last post by:
Hi, I am working in VS2005 (VB) environment and I have following problem: On one of my web pages I use Datagrid control which I dynamically load. I also use numerical paging with Datagrid....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...

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.