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

Conditionally Hide Select Column of GridView ?

I have populated the Child Accounts and Parent Accounts in a Grid View
Control, I want to hide the Select Column of Parent Accounts, but not the
Child Accounts, is it possible ?

I am using VS 2005 ?

Best Regards,

Luqman
Jul 8 '07 #1
4 5985
"Luqman" <pe*******@cyber.net.pkwrote in message
news:ev**************@TK2MSFTNGP06.phx.gbl...
>I have populated the Child Accounts and Parent Accounts in a Grid View
Control, I want to hide the Select Column of Parent Accounts, but not the
Child Accounts, is it possible ?

I am using VS 2005 ?
Not sure what you mean by "Child Accounts" and "Parent Accounts"...

When you say you want to "hide" the column, does that mean that you still
want it to be rendered to the client but invisible, or you don't want it to
be rendered at all...?

I'm guessing the latter, in which case:

MyGridView.Columns[n].Visible = false;
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 8 '07 #2

No, I mean, I want to hide select Column Cell for the particular Rows, for
example: it should be visible for row no. 1 but hide for row no. 2

I want this to be done when the gridview is filling, if field tag='Y' then
gridview select column cell should be visible otherwise it should be hide or
disable or user should not be able to click on Select of that particular
Row.

Any idea please ?

Best Regards,

Luqman
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eD**************@TK2MSFTNGP03.phx.gbl...
"Luqman" <pe*******@cyber.net.pkwrote in message
news:ev**************@TK2MSFTNGP06.phx.gbl...
I have populated the Child Accounts and Parent Accounts in a Grid View
Control, I want to hide the Select Column of Parent Accounts, but not the
Child Accounts, is it possible ?

I am using VS 2005 ?

Not sure what you mean by "Child Accounts" and "Parent Accounts"...

When you say you want to "hide" the column, does that mean that you still
want it to be rendered to the client but invisible, or you don't want it
to
be rendered at all...?

I'm guessing the latter, in which case:

MyGridView.Columns[n].Visible = false;
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 10 '07 #3
"Luqman" <pe*******@cyber.net.pkwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
No, I mean, I want to hide select Column Cell for the particular Rows, for
example: it should be visible for row no. 1 but hide for row no. 2
Ah, so you don't actually want to hide the column (as per your subject), but
rather individual cells in a column...
I want this to be done when the gridview is filling, if field tag='Y' then
gridview select column cell should be visible otherwise it should be hide
or
disable or user should not be able to click on Select of that particular
Row.
<asp:GridView ID="MyGridView" runat="server"
OnRowDataBound="MyGridView_RowDataBound" ...>
...
</asp:GridView ID>

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Controls[0].Visible = e.Row.Cells[1].Text == "Y";
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 10 '07 #4
Hi Mark,

Thats what exactly I wanted,thanks very much.

Best Regards,

Luqman

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:#B**************@TK2MSFTNGP05.phx.gbl...
"Luqman" <pe*******@cyber.net.pkwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
No, I mean, I want to hide select Column Cell for the particular Rows,
for
example: it should be visible for row no. 1 but hide for row no. 2

Ah, so you don't actually want to hide the column (as per your subject),
but
rather individual cells in a column...
I want this to be done when the gridview is filling, if field tag='Y'
then
gridview select column cell should be visible otherwise it should be
hide
or
disable or user should not be able to click on Select of that particular
Row.

<asp:GridView ID="MyGridView" runat="server"
OnRowDataBound="MyGridView_RowDataBound" ...>
...
</asp:GridView ID>

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Controls[0].Visible = e.Row.Cells[1].Text == "Y";
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 13 '07 #5

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

Similar topics

6
by: Das | last post by:
Hi everyone, I'm using datagrid control to display the data. I want to hide column to be displayed into the data grid. I'm using the code as given below: Method given below is used to bind the...
2
by: Thanh Nu | last post by:
Hi, I would like to hide a column in a web datagrid (with create columns automatically at runtime checked), and I cannot refer to the columns collection like this: DataGrid1.Columns(0).Visible...
3
by: sivaraman.S | last post by:
Hi friends, How to hide a column in datagrid. regards, Sivaraman.S
3
by: Jason | last post by:
How do I hide a column in a GridView in ASP.NET 2.0 when all of the columns are autogenerated based on the datasource? I want to hide the first of three columns, but the following doesn't work: ...
9
by: ghostwolf | last post by:
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.
0
by: Greg Smith | last post by:
I would like to assign the value of a column to the text of the 'Select' column. i.e. In stead of 'Select' it would have the value in the column. Is this do-able? Any help is greatly...
0
by: =?ISO-8859-1?Q?=22Fernando_A=2E_G=F3mez_F=2E=22?= | last post by:
Hello all, I have an ASP.NET page with a GridView bounded to a DataSource. When I click the edit button/link, I'm able to update the data with no problemos. However, if further in my code I hide...
1
by: coreyk | last post by:
I have been trying for ever to hide a column in gridview using the following code, GridView1.Columns.Visible = false; but the debugger says that index is out of range, the number columns when...
1
by: John Cazaly | last post by:
I have what wouold at first seem a simple request: to create a datagrid / View or similar for an Orders table with OrdID and OrderDate fields (plus some others). I want to select OrderDaate >= From...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
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...

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.