.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sharon Maxwell

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Hide GridView column

Posted By: Ramesh     Posted Date: May 28, 2010    Points:2   Category :ASP.Net
I have a GridView that I want to hide a whole column based on a condition known before it is Databound. Is the best place to do this in RowDatabound or in PreRender or ?


Author: Sunil Yadav       [Moderator]   Accepted Answer   
Posted Date: May 28, 2010     Points: 10   


you can use following line of code.

GridView1.Columns[1].Visible = false;

The best way would be adding it on pre-render event from the performance point of view.Since you can hiding column befor databound so row databound is out of question.But i doubt since you are hiding column before databound no columns will e visible to you.

Author: Lalij Mer             
Posted Date: May 28, 2010     Points: 5   

Try this link


Please Check my answer if you help....
Thank You...

Author: BangaruBabuPureti             
Posted Date: May 31, 2010     Points: 5   

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

BangaruBabu Pureti

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend