473,699 Members | 2,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(XmlElem ent objStorageGroup in objServer.Child Nodes)
{
this.intMbSG = 0;
this.objDataGri d =
this.GetDataGri d(objStorageGro up.Attributes["Name",""].Value);
this.objDataGri d.Font.Bold = true;
this.objDataGri d.BackColor = System.Drawing. Color.Gray;
this.objDataGri d.ForeColor = System.Drawing. Color.White;
this.objDataGri d.HeaderStyle.H orizontalAlign = HorizontalAlign .Center;
this.PlaceHolde r1.Controls.Add (this.objDataGr id);
this.objDataGri d = new DataGrid();
this.objDataGri d.ItemDataBound += new
DataGridItemEve ntHandler(objDa taGrid_ItemData Bound);
this.objDataGri d.ItemCreated += new
DataGridItemEve ntHandler(objDa taGrid_ItemCrea ted);
DataTable objTable = new DataTable();
objTable.Column s.Add(new DataColumn("Sto re Name",typeof(st ring)));
objTable.Column s.Add(new DataColumn("Mai lboxes",typeof( string)));
objTable.Column s.Add(new DataColumn("Quo ta",typeof(stri ng)));
foreach(XmlElem ent objStore in objStorageGroup .ChildNodes)
{
DataRow objRow = objTable.NewRow ();
objRow[0] = objStore.Attrib utes["Name",""].Value;
objRow[1] = objStore.ChildN odes[0].Attributes["Count",""].Value;
objRow[2] = objStore.ChildN odes[1].Attributes["Count",""].Value;
objTable.Rows.A dd(objRow);
this.intMbSG = this.intMbSG +
Convert.ToInt32 (objStore.Child Nodes[0].Attributes["Count",""].Value);
}
this.objDataGri d.DataSource = new DataView(objTab le);
this.objDataGri d.DataBind();
this.objDataGri d.Columns[2].Visible = false;
this.objDataGri d.Width = 500;
this.objDataGri d.Font.Name = "Verdana";
this.objDataGri d.Font.Size = 10;
this.objDataGri d.HeaderStyle.F ont.Bold = true;
this.objDataGri d.BackColor = System.Drawing. Color.DarkOrang e;
this.objDataGri d.ItemStyle.Bac kColor = System.Drawing. Color.White;
this.objDataGri d.AlternatingIt emStyle.BackCol or =
System.Drawing. Color.White;
this.PlaceHolde r1.Controls.Add (this.objDataGr id);
this.objDataGri d = this.GetDataGri d("Mailboxes in Storage
Group",this.int MbSG);
this.PlaceHolde r1.Controls.Add (this.objDataGr id);
this.intMbServe r = this.intMbServe r + this.intMbSG;
}
....

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

What am I doing wrong???

Thanks in advance!!!

Mark

Nov 17 '05 #1
0 1134

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

Similar topics

2
2126
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
2623
by: MrNobody | last post by:
I found some tutorial which had the following example for hiding columns in a DataGrid: http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/datagrid7.src&file=CS\datagrid7.aspx&font=3 The problem is, I have no "Columns" property on my DataGrid! I'm using Visual C# .NET IDE, which has version 1.1 of the framework. Do I need a more advanced version of the framework?
0
1180
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 only 2 levels deep. XML: <Customers id="123" name="Joe" level="A">
1
840
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 controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
0
1340
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 respective tables SELECTed in the select-queries, so that I may use that field as the DataKeyField of my datagrid. But when I set the dataset produced from my data adapter
7
1439
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
3182
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 to change it to visible=true. You can't do that with a bound column (no ID), but you can create a templatecolumn with a label. To make these visible, I am going through each datagriditem and making them visible after I have bound the data to...
5
3696
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 Identifier column so that I can run updates on the SqlAdapter object. Is there a way to hide this column from the datagrid? Dim dv1 As New DataView(ds.Tables("tbl1")) dv1.AllowNew = False dgr1.DataSource = dv1 '--dgr1 is the datagrid
1
1375
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 want to do is hiding and unhiding the column at the run time without the post back to the server. have anyone come across with such a kind of scenario please do suggest
1
1816
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 void gvLocations_edit(object sender, GridViewEditEventArgs e) { // load the record details into the edit fields // GridView gvRecord = (GridView)sender; string sThisRecord = gvRecord.Rows.Cells.Text; ...
0
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8617
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8884
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.