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

Hide Datagrid Column via client side scripting (Javascript)

Rob
Does anyone know how I could hide a column in a DataGrid? To make the
problem harder I am using AutoGenerateColumns="True" so I don't know
how to find the control using document.getElementById(ControlID) and
then hiding it by using display:none;

Anyone have any suggestions?

Thanks for the help.

Dec 5 '05 #1
7 3750
You know the grid id. It lets you find the table the grid is rendered as.
The first row of the table contains the column headers. If you know the
column header text, you can loop through the cells of the first row and find
the one with the innerText matching the required header text. In this way
you find out the index of the required column in the row. Then loop through
the rest of the rows and set display:none for the cell with the required
index.

Eliyahu

"Rob" <Ro*******@Yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Does anyone know how I could hide a column in a DataGrid? To make the
problem harder I am using AutoGenerateColumns="True" so I don't know
how to find the control using document.getElementById(ControlID) and
then hiding it by using display:none;

Anyone have any suggestions?

Thanks for the help.

Dec 6 '05 #2
Why don't you simply do :
yourDataGrid.Columns[columnIndex].Visible = false;
Patrick
"Rob" <Ro*******@Yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Does anyone know how I could hide a column in a DataGrid? To make the
problem harder I am using AutoGenerateColumns="True" so I don't know
how to find the control using document.getElementById(ControlID) and
then hiding it by using display:none;

Anyone have any suggestions?

Thanks for the help.

Dec 6 '05 #3
Patrick,

Firstly, autogenerated columns don't appear in Columns collection.
Secondly, the OP is looking for a client-side solution.

Eliyahu

"Patrick.O.Ige" <na********@toughguy.net> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Why don't you simply do :
yourDataGrid.Columns[columnIndex].Visible = false;
Patrick
"Rob" <Ro*******@Yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Does anyone know how I could hide a column in a DataGrid? To make the
problem harder I am using AutoGenerateColumns="True" so I don't know
how to find the control using document.getElementById(ControlID) and
then hiding it by using display:none;

Anyone have any suggestions?

Thanks for the help.


Dec 6 '05 #4
Rob do u mean by hiding column hiding text or hiding whatever inside
that cloumn (may be some other controls too)?

Dec 6 '05 #5
Rob
Yes, hiding the entire contents of the column in the autogenerated
datagrid. Previously I have been using .Visible=false but a round trip
to the server is too slow.

I think Eliyahu Goldin has what I am looking for however I am not sure
I know how to work through the solution. Does anyone have an example
of this?
Thanks in advance for the help.

Dec 6 '05 #6
Basically, you just need to browse through the table DHTML object. Look it
up in the MSDN library. The online version is here:
http://msdn.microsoft.com/library/de...ects/table.asp

You will find there all properties you need: the collections of rows and
cells.

Eliyahu

"Rob" <Ro*******@Yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Yes, hiding the entire contents of the column in the autogenerated
datagrid. Previously I have been using .Visible=false but a round trip
to the server is too slow.

I think Eliyahu Goldin has what I am looking for however I am not sure
I know how to work through the solution. Does anyone have an example
of this?
Thanks in advance for the help.

Dec 6 '05 #7
Sorry though i didn't notice the AutoGenerateColumns.

"Patrick.O.Ige" <na********@toughguy.net> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Why don't you simply do :
yourDataGrid.Columns[columnIndex].Visible = false;
Patrick
"Rob" <Ro*******@Yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Does anyone know how I could hide a column in a DataGrid? To make the
problem harder I am using AutoGenerateColumns="True" so I don't know
how to find the control using document.getElementById(ControlID) and
then hiding it by using display:none;

Anyone have any suggestions?

Thanks for the help.


Dec 7 '05 #8

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

Similar topics

27
by: Nicholas Couch | last post by:
I have a little form with a couple of dynamically generated list boxes. When the user makes a selection from the first box, the second box is refreshed. When they make a selection from the second...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
11
by: Hrvoje Vrbanc | last post by:
Hello, I have the following problem: I have a DataGrid control on my page with a column with TextBox controls and another one with ImageButton controls. In order to force a call to JavaScript...
2
by: | last post by:
I have a page where I have 3 combo boxes listed in a column. sort of like: combo1 combo2 combo3 Based on which one is clicked, the others are supposed to hide (i.e. combobox.visible =...
2
by: Paul | last post by:
If it's possible I would like to perform some client side actions on my Visual Basic asp.net application. An example of what I'm trying to do. I have a DATAGRID with columns ITEM, ITEMTYPE and a...
2
by: Mike | last post by:
I have a datagrid were i want to allow the user to select a row then click a delete button and delete that row. I do not want to have a button in every row, i want 1 button for the delete. How can...
3
by: Leo | last post by:
I have a datagrid with the first column as a Edit,Update,Cancel button column. The other 5 columns are template columns. When I click the Edit button in IE6 the row correctly displays the...
0
by: dotnet dude | last post by:
I am creating a DataGrid control (ASP.NET 1.) with few bound columns and one template column in which i want to display CheckBox. So for each row in datagrid some databound fields and a checkbox...
7
by: rn5a | last post by:
The first column of a DataGrid has a CheckBox for all the rows. I want that when users check a CheckBox, the BackColor of that entire row in the DataGrid should change to a different color. To...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.