Solved

Gridview redisplays hidden columns afer postback

Posted on 2016-09-23
2
65 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:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
zephyr_hex (Megan) 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:Charles Baldo
ID: 41813175
Thank You
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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