Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 20th, 2005, 08:40 AM
Authorized User
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET Datagrid Autogenaratedcolunm Hide Problem

Hi all,
           I am not Able to hide Autogenarated Column at runtime.

Please any body help me.

I have Three Auto generated Column Product_Id,Product_Name,Price and want to hide Product_Id column at run time when Click Edit Link Button.

            My code:-----

Ctype(e.Item.Cells(3).Controls(0), TextBox).visible = False

            Thows an error.

But it is working fine in UpdateCommandColumn

Dim PId as String = & _
 Ctype(e.Item.Cells(3).Controls(0), TextBox).Text

How can I Trap that Event to Hide the control or Hide entire Column.

   Wating for reply.

Thanks in Advance

Shubhajyoti Ghosh.

Old February 6th, 2005, 06:12 PM
Registered User
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

To my knowledge you can't hide autogenerated columns, my suggestion is when you want to modify any of the columns, width, header, visible, then set autogenerate columns to false, and then add the columns manually
Old February 28th, 2005, 03:14 AM
Registered User
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sreeramulu

Hi There,
     There is solution in datagrid itself. You first try to find out which column u wish to hide. Then add line to code

I guess that this will solve your problem.


Old March 2nd, 2005, 10:59 PM
Registered User
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

this will not work :

instead you have to bind the ItemDataBound event and using the DataGridItemEventArgs item to hide the dynamic column. for eg :

private void dg_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    e.Item.Cells[3].Visible = false;

Similar Threads
Thread Thread Starter Forum Replies Last Post
hide/unhide columns in datagrid drachx ADO.NET 1 March 26th, 2005 01:46 PM
could i hide a column at run time from datagrid alyeng2000 ASP.NET 1.0 and 1.1 Basics 10 January 17th, 2004 03:26 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.