Solved

Gridview redisplays hidden columns afer postback

Posted on 2016-09-23
2
35 Views
Last Modified: 2016-09-23
I am using a .net gridview in a web form that has some columns hidden

The gridview has AutoGeneratColumns=false.  Everything displays fine. The cells are made invisible on the RowDataBound event.  When I save a record to the database in a table not in the gridview the grid redraws and my columns that were invisible are suddenly visible.

I can not find an event that is firing that would do that,  I have set all the ONROWxxx Events on and put a debug statement at each one but do not see which is firing so that I can re-invisble the columns.

Thank you
0
Comment
Question by:charlesbaldo
2 Comments
 
LVL 42

Accepted Solution

by:
zephyr_hex earned 500 total points
ID: 41812945
Is there a reason why you're setting the columns to hidden on RowDataBound ?  I'm assuming you only bind the data to the control when the page first loads (not on postback).

You can hide columns in Page_Load:
if(IsPostBack)  //if you keep your RowDataBound column hiding, then only do this when it's not postback.  or, remove the hiding from RowDataBound and always hide the column here regardless of whether it's postback
{
   Gridview1.Columns[0].Visible = false;  //hide first column of GridView1
}

Open in new window

0
 

Author Closing Comment

by:charlesbaldo
ID: 41813175
Thank You
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now