Solved

Gridview redisplays hidden columns afer postback

Posted on 2016-09-23
2
50 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 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:charlesbaldo
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

Suggested Solutions

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!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

840 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