CodeSnip: Hiding Columns using GridView
page 4 of 4
by Sachin Dedhia
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 44667/ 27

In a Nutshell

In this article you have learned how to hide columns using GridView control using ASP.NET 2.0. Happy coding!


View Entire Article

User Comments

Title: 2012 NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-05-20 11:31:25 PM
Comment:
[/pre]Cheap NFL,NBA,MLB,NHL
[url=http://www.jersey2shop.com/]Jerseys From China[/url]
[url=http://www.jersey2shop.com/]2012 nike nfl Jerseys[/url]
[url=http://www.jersey2shop.com/]cheap China Jerseys[/url]
[url=http://www.jersey2shop.com/]Sports Jerseys China[/url]
[url=http://www.jersey2shop.com/NFL-Jerseys-c68/]NFL Jerseys China[/url]
[url=http://www.jersey2shop.com/NBA-Jerseys-c77/]NBA Jerseys China[/url]
NHL Jerseys China
[url=http://www.jersey2shop.com/MLB-Jerseys-c94/]MLB Jerseys China[/url]NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
[/pre]
[pre]We Are Professional China jerseys Wholesaler
[url=http://www.cheapjersey2store.com/]Wholesale cheap jerseys[/url]Cheap mlb jerseys
[url= http://www.cheapjersey2store.com/]2012 mlb all atar jerseys[/url]
[url= http://www.cheapjersey2store.com/ [/url]Cheap China Wholesael[/url]
[url= http://www.cheapjersey2store.com/]Wholesale jerseys From China[/url]
[url=http://www.cheapjersey2store.com/]2012 nike nfl Jerseys[/url]Free Shipping,Cheap Price,7 Days Deliver
[/pre]
[/pre]
We are professional jerseys manufacturer from china,wholesal
sports [url= http://www.cheapjersey2store.com/]Jerseys From China[/url]
[url=http://www.cheapjersey2store.com/NFL-Jerseys-c68]NFL jerseys China[/url]
[url=http://www.cheapjersey2store.com/NHL-Jerseys-c96/]NHL Jerseys China[/url]
[url=http://www.cheapjersey2store.com/NBA-Jerseys-c77/]NBA Jerseys China[/url]
[url=http://www.cheapjersey2store.com/MLB-Jerseys-c94/]MLB Jerseys China[/url]
[url= http://www.cheapjersey2store.com/]China Jerseys[/url],Free Shipping
[/pre]
[/pre]
We are professional jerseys manufacturer from china,wholesal
sports [url= http://www.jerseycaptain.com/]cheap jerseys sale online [/url]
[url= http://www.jerseycaptain.com/]2012 nike nfl Jerseys[/url]
[url=http://www.jerseycaptain.com/NFL-Jerseys-c68]cheap NFL jerseys China[/url]
[url=http://www.jerseycaptain.com/NHL-Jerseys-c96/]NHL Jerseys C
Title: dss   
Name: dfsdfs
Date: 2012-04-30 6:06:37 AM
Comment:
gfdgfdg
Title: Miss.   
Name: Akansha
Date: 2011-10-05 4:23:22 AM
Comment:
Thank you soooo much...U code made it so easy..!!!
Title: Mr.   
Name: Sanjay Khandagale
Date: 2011-09-13 10:26:20 AM
Comment:
You can handle the GridView_RowBound event and make the cell of which the column need to hide invisible like followin

protected void gdvAgency_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[1].Visible = false;
}

Here my first column was select button and second one agency Id I am hiding autoid column here.
Title: thanks a lot   
Name: chaitanya
Date: 2010-08-02 4:06:36 AM
Comment:
your articel is very helpfull :)
Title: ss   
Name: snehal
Date: 2010-02-24 1:23:54 AM
Comment:
I was tring to 'hide' the visibility of the gridview column after databound ... that was not working.
in page load
Title: Thanks   
Name: S
Date: 2010-02-22 4:17:05 PM
Comment:
Thanks alot.

I was using the ObjectDataSource with my gridview.

I was tring to 'hide' the visibility of the gridview column after databound ... that was not working.

I was just about to give up on using the ObjectDataSource and do the databinding in code.

Your solution works great.

Thanks alot.
Title: Another solution - correction   
Name: Gunnar
Date: 2010-01-27 12:19:53 PM
Comment:
//Sorry some of the code was missing
protected void ExpandCol(object sender, EventArgs e)
{
GridView1.Columns[0].Visible = true;

for (int i = 0; i < GridView1.Rows[i].Cells.Count; i++)
{
for (int j = 0; j < GridView1.Rows[i].Cells.Count; j++)
{
GridView1.Rows[i].Cells[j].Visible = true;
}
}
}
Title: Another Solution   
Name: Gunnar
Date: 2010-01-27 12:03:31 PM
Comment:
Thanks for your solution.
Another approach ist to databind first and then hide columns in the code behind page
...
GridView1.DataBind();
GridView1.Columns[0].Visible = false;
...
//function (codebehind) which shows the data
//called from any asp.net-control)
protected void ExpandCol(object sender, EventArgs e)
{
GridView1.Columns[0].Visible = true;
}
Title: Ms   
Name: Dee
Date: 2009-08-28 6:37:01 AM
Comment:
I get index out of Arg out range exception?? This does not work
Title: Great Thanks!!   
Name: Nripin Babu
Date: 2009-07-29 6:39:22 AM
Comment:
Great Thanks!!
Title: A better way   
Name: Waqar Ahmad
Date: 2009-05-22 2:06:44 AM
Comment:
on page load event

myGridView.Column[0].Visisble = false;

Row Created event will be called upon each row.. however there are some cases where we may need to use this event
Title: Thank u so much   
Name: Viji
Date: 2009-05-16 5:30:02 AM
Comment:
wow... Thank you so much... I was breaking my head to do this... This article helped me a lot... Thank u..
Title: Nice solution   
Name: Angel
Date: 2009-04-15 1:56:24 AM
Comment:
tnks men, you save my money and time.
Title: Saved Time   
Name: Ed McPeak
Date: 2009-02-23 7:29:00 PM
Comment:
Excellent! You rock! Saved me tons of hours!!!
Title: How I can make it work on C#   
Name: Sachin Dedhia
Date: 2008-12-04 1:07:14 AM
Comment:
Nelson,
Select the GridView control on you page. Bring up the properties window. Click on the "Events" botton (looks like flash/thunder symbol). You will get a list of events from where you double-click "RowCreated" event.

Further, since you are new to ASP.NET, I suggest you take some help from your colleagues.
Title: How I can make it work on C#   
Name: Nelson
Date: 2008-12-02 11:03:06 PM
Comment:
I am new on ASP, and couldn't make it work on C sharp, were on code should I put it?
Title: Works Great   
Name: Yvette
Date: 2008-11-22 3:27:28 PM
Comment:
I kept getting an Argument Out of Range exception so I put the code in a Try block and it solved all my problems. Thanks!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 7:06:44 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search