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

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 8649
To hide the third column for example ...

GridView.Columns[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.com.hkwrote in message
news:OA**************@TK2MSFTNGP04.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.Columns[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**@markNOSPAMrae.comwrote in message
news:eS*************@TK2MSFTNGP06.phx.gbl...
"ghostwolf" <yl***@roctec.com.hkwrote in message
news:OA**************@TK2MSFTNGP04.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.Columns[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.com.hkwrote in message
news:O4**************@TK2MSFTNGP05.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.DataSource = <datasource>;
MyGridView.Columns[0].Visible = true;
MyGridView.DataBind();
MyGridView.Columns[0].Visible = false;
Aug 4 '06 #5
Check this out..

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

"ghostwolf" <yl***@roctec.com.hkwrote in message
news:OA**************@TK2MSFTNGP04.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**************@TK2MSFTNGP03.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**@markNOSPAMrae.comwrote in message
news:Oh**************@TK2MSFTNGP06.phx.gbl...
"Winista" <wi*****@gmail.comwrote in message
news:uJ**************@TK2MSFTNGP03.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$****************@TK2MSFTNGP04.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**@markNOSPAMrae.comwrote in message
news:um****************@TK2MSFTNGP03.phx.gbl...
"Winista" <wi*****@gmail.comwrote in message
news:u$****************@TK2MSFTNGP04.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
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...
4
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...
0
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...
0
by: Mat | last post by:
Is it possible to call a vbscript function from the gridview's properties (like the TEXT propertie)?
0
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...
3
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>...
0
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...
1
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...
5
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.