Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Gridview redisplays hidden columns afer postback

Posted on 2016-09-23
2
Medium Priority
?
81 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 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 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