Solved

Gridview redisplays hidden columns afer postback

Posted on 2016-09-23
2
56 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

749 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