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

Hiding column in ASP datagrid

Hi,

I am trying to hide a column in a datagrid I dynamicaly created, but
fail to with the following code:

....
....
foreach(XmlElement objStorageGroup in objServer.ChildNodes)
{
this.intMbSG = 0;
this.objDataGrid =
this.GetDataGrid(objStorageGroup.Attributes["Name",""].Value);
this.objDataGrid.Font.Bold = true;
this.objDataGrid.BackColor = System.Drawing.Color.Gray;
this.objDataGrid.ForeColor = System.Drawing.Color.White;
this.objDataGrid.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
this.PlaceHolder1.Controls.Add(this.objDataGrid);
this.objDataGrid = new DataGrid();
this.objDataGrid.ItemDataBound += new
DataGridItemEventHandler(objDataGrid_ItemDataBound );
this.objDataGrid.ItemCreated += new
DataGridItemEventHandler(objDataGrid_ItemCreated);
DataTable objTable = new DataTable();
objTable.Columns.Add(new DataColumn("Store Name",typeof(string)));
objTable.Columns.Add(new DataColumn("Mailboxes",typeof(string)));
objTable.Columns.Add(new DataColumn("Quota",typeof(string)));
foreach(XmlElement objStore in objStorageGroup.ChildNodes)
{
DataRow objRow = objTable.NewRow();
objRow[0] = objStore.Attributes["Name",""].Value;
objRow[1] = objStore.ChildNodes[0].Attributes["Count",""].Value;
objRow[2] = objStore.ChildNodes[1].Attributes["Count",""].Value;
objTable.Rows.Add(objRow);
this.intMbSG = this.intMbSG +
Convert.ToInt32(objStore.ChildNodes[0].Attributes["Count",""].Value);
}
this.objDataGrid.DataSource = new DataView(objTable);
this.objDataGrid.DataBind();
this.objDataGrid.Columns[2].Visible = false;
this.objDataGrid.Width = 500;
this.objDataGrid.Font.Name = "Verdana";
this.objDataGrid.Font.Size = 10;
this.objDataGrid.HeaderStyle.Font.Bold = true;
this.objDataGrid.BackColor = System.Drawing.Color.DarkOrange;
this.objDataGrid.ItemStyle.BackColor = System.Drawing.Color.White;
this.objDataGrid.AlternatingItemStyle.BackColor =
System.Drawing.Color.White;
this.PlaceHolder1.Controls.Add(this.objDataGrid);
this.objDataGrid = this.GetDataGrid("Mailboxes in Storage
Group",this.intMbSG);
this.PlaceHolder1.Controls.Add(this.objDataGrid);
this.intMbServer = this.intMbServer + this.intMbSG;
}
....

It crashes on : this.objDataGrid.Columns[2].Visible = false; >> Index
out of range.

What am I doing wrong???

Thanks in advance!!!

Mark

Nov 17 '05 #1
0 1124

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

Similar topics

2
by: Kevin | last post by:
Hi Al Can someone tell me how to hide colums in a datagrid. I have a one datagrid that is a master and child and I would like to hide specific columns, how do I do this TI Kevin
2
by: MrNobody | last post by:
I found some tutorial which had the following example for hiding columns in a DataGrid: ...
0
by: lanky_tx | last post by:
Hello, I am trying to hide a column in a child table within a windows form DataGrid control. I am populating the Datagrid datasource with an dataset which is populated with hierarchical XML...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
0
by: Michelle Stone | last post by:
I have several Data Adapters, and depending on certain conditions, I set one of them as the DataSource for a datagrid on my web form. In each of the data adapters, I have the primary key of the...
7
by: David Freeman | last post by:
Hi There! Below is my VB.NET code... Dim strSQL As String strSQL = "SELECT , FROM Customers GROUP BY , , " Dim oleConn As OleDbConnection = Nothing
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
5
by: Rich | last post by:
I have a datagrid that uses a dataview object for its datasource. The dataview contains a unique row identifier column. I don't want to display this column in the datagrid. I need the unique row...
1
by: jack | last post by:
Hi all, My datagrid have too many columns which are going out of screen. one of the solution is to group the columns and make only the total column visible at the initial stage. What now i...
1
by: Dica | last post by:
i need to allow the user to select a row from my dataGrid for editing. as such, i include the record ID in the first column and then extract like so when retrieving the record details: protected...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.