473,698 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide a column in asp:GridView

Hi, I want to hide a column in the asp:GridView, say one of the column of
asp:BoundField. But it is not allowed to put <divinside for setting it
display:none. What can I do? Thanks in millions.
Aug 4 '06 #1
9 8677
To hide the third column for example ...

GridView.Column s[2].Visible = false;

"ghostwolf" wrote:
Hi, I want to hide a column in the asp:GridView, say one of the column of
asp:BoundField. But it is not allowed to put <divinside for setting it
display:none. What can I do? Thanks in millions.
Aug 4 '06 #2
"ghostwolf" <yl***@roctec.c om.hkwrote in message
news:OA******** ******@TK2MSFTN GP04.phx.gbl...
Hi, I want to hide a column in the asp:GridView, say one of the column of
asp:BoundField. But it is not allowed to put <divinside for setting it
display:none. What can I do? Thanks in millions.
MyGridView.Colu mns[0].Visible = false;

HOWEVER, bear in mind that this isn't actually *hiding* the column per se -
it's physically *removing* the column from the HTML being sent down to the
client, which may not be what you really want...
Aug 4 '06 #3
thanks, actually I don't really want to invisible it. It is because I want
to put a value for each row but make it hide away. Just like what we did in
windows programming for adding a value for each row. If I make the column in
asp:GridView invisible, I cannot get the value from that column.

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:eS******** *****@TK2MSFTNG P06.phx.gbl...
"ghostwolf" <yl***@roctec.c om.hkwrote in message
news:OA******** ******@TK2MSFTN GP04.phx.gbl...
>Hi, I want to hide a column in the asp:GridView, say one of the column of
asp:BoundField . But it is not allowed to put <divinside for setting it
display:none . What can I do? Thanks in millions.

MyGridView.Colu mns[0].Visible = false;

HOWEVER, bear in mind that this isn't actually *hiding* the column per
se - it's physically *removing* the column from the HTML being sent down
to the client, which may not be what you really want...

Aug 4 '06 #4
"ghostwolf" <yl***@roctec.c om.hkwrote in message
news:O4******** ******@TK2MSFTN GP05.phx.gbl...
thanks, actually I don't really want to invisible it. It is because I want
to put a value for each row but make it hide away. Just like what we did
in windows programming for adding a value for each row. If I make the
column in asp:GridView invisible, I cannot get the value from that column.
Ah... You've discovered the additional security feature that a GridView has
but a DataGrid didn't.

Basically, Microsoft took the view that using hidden columns to store data
was a potential security risk, so they removed hidden colums from ViewState
at databind time. However, it's easy enough to work round, but be aware of
the potential security risk involved in doing this...

MyGridView.Data Source = <datasource>;
MyGridView.Colu mns[0].Visible = true;
MyGridView.Data Bind();
MyGridView.Colu mns[0].Visible = false;
Aug 4 '06 #5
Check this out..

http://www.netomatix.com/development...ideColumn.aspx

"ghostwolf" <yl***@roctec.c om.hkwrote in message
news:OA******** ******@TK2MSFTN GP04.phx.gbl...
Hi, I want to hide a column in the asp:GridView, say one of the column of
asp:BoundField. But it is not allowed to put <divinside for setting it
display:none. What can I do? Thanks in millions.

Aug 4 '06 #6
"Winista" <wi*****@gmail. comwrote in message
news:uJ******** ******@TK2MSFTN GP03.phx.gbl...
Check this out..

http://www.netomatix.com/development...ideColumn.aspx
Correct approach, terrible implementation!

Need to set display to either none or block to make this work properly.
Aug 4 '06 #7
Thank you for pointing out the issue with the approach. It has been fixed on
the site as well as attached demo project.

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:Oh******** ******@TK2MSFTN GP06.phx.gbl...
"Winista" <wi*****@gmail. comwrote in message
news:uJ******** ******@TK2MSFTN GP03.phx.gbl...
>Check this out..

http://www.netomatix.com/development...ideColumn.aspx

Correct approach, terrible implementation!

Need to set display to either none or block to make this work properly.

Aug 4 '06 #8
"Winista" <wi*****@gmail. comwrote in message
news:u$******** ********@TK2MSF TNGP04.phx.gbl. ..
Thank you for pointing out the issue with the approach. It has been fixed
on the site as well as attached demo project.
Excellent. Check this out for cross-browser compatibility
http://www.quirksmode.org/css/display.html, but I think you're OK... :-)
Aug 4 '06 #9
Thanks, it's great for me.

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:um******** ********@TK2MSF TNGP03.phx.gbl. ..
"Winista" <wi*****@gmail. comwrote in message
news:u$******** ********@TK2MSF TNGP04.phx.gbl. ..
>Thank you for pointing out the issue with the approach. It has been fixed
on the site as well as attached demo project.

Excellent. Check this out for cross-browser compatibility
http://www.quirksmode.org/css/display.html, but I think you're OK... :-)

Aug 7 '06 #10

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

Similar topics

4
5306
by: WayDownUnder | last post by:
I am trying to findout which column the user clicked on in a gridview. column 0 = CommandField ( view) column 1 = CommandFiled ( edit) When the event grdTemp_SelectedIndexChanged occurs on the server I want to know which column was selected eg do somthing when view pressed do somthing else when edit pressed. Thanks in advance
4
1494
by: saturnius | last post by:
Hello, I have to save the data from a gridview as XML file. The code is shown below. Is there no easier way? I would like to access either asp:SqlDataSource (me.SqlDataSource1.something) or asp:GridView (me.GridView1.something) instead I have to create a new sqlcon,selectcommand,dataset,dataadapter.... Is there no easier way?
0
1270
by: GMartin | last post by:
What are my best options for sorting a grid by it's Template Column? I have a Template Column with Checkmarks, and want the user to be able to click on a header button, and have all the "selected" ones, come to the top. The only thing I can think of is binding it to a dataset that has a "checked" column added to store the info, and then sorting on that. Hoping there might be an easier way.
0
1073
by: Mat | last post by:
Is it possible to call a vbscript function from the gridview's properties (like the TEXT propertie)?
0
3448
by: Reinhard | last post by:
Hi, Need some directions on Ajax, UpdatePanel and Gridview to achive the following: I like to show a Gridview with Data ONLY if the user is interested in Details, but without a full page reload! If the page loads, only a summary (eg. COUNT of recs) should be displayed
3
8458
by: mudassir368 | last post by:
--This is the html code <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="Agent Name"> <ItemTemplate> <asp:Label ID="lblagentname" runat="server" Text='<%#Bind("AgentName") %>'></asp:Label>
0
2691
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer row. I would like to display the footer row, only when a LinkButton "Add New" is clicked. And after the new record is saved to the database, let the footer row disappear. In the LinkButton's click event handler, I simply say:
1
1632
by: David C | last post by:
I have a GridView that I am exporting to Excel and it works fine. However, the 1st and last columns have Edit and Delete command links and I do not want to export them. Is there a way to do this before I render it? Thanks. David
5
4237
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I am using <asp:Gridview> to display my data. I am adding columns and rows dynamically. I am facing following issues: 1. I want scrollbars around the gridview and for this purpose i used <div style="overflow:auto"> and its working fine. But issue is that the header row also scroll down with scrollbar and i want to fix header row . I searched on google and found a lot of solutions but nothing is working for me. I am using css for...
0
8678
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
8609
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
9166
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...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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
7737
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
6525
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
4371
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...
0
4621
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.