Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
| Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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
  #1 (permalink)  
Old October 7th, 2004, 08:02 PM
Authorized User
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default hide/unhide columns in datagrid

hi guys,

i have colmn 1 ,2,5,6
how do i trigger events that when i enter certain string in column1 it will display column 3 and 4, but for another string that i've enter in column 1 it will hide column 3 ,4
in datagrid
tnx in advanced
  #2 (permalink)  
Old March 26th, 2005, 01:46 PM
Registered User
Join Date: Dec 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts


After you enter the string which should show columns 3 and 4 , the datagrid should be rebound with the new values. Whenever the datagrid is rebound, the itemdatabound event is fired. In this event, the value id column 1 can be checked and depending on its value the columns 3 and 4 can be shown or hidden .

the sample code is as follows

Private Sub Datagrid1_ItemDataBound(ByVal sender As System.Object, ByVal e As DataGridItemEventArgs) Handles dgrPrograms.ItemDataBound

If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then

if e.item.Cells(1).text = "String1" then

e.item.Cells(3).visible = true
e.item.Cells(4).visible = true

elseif e.item.Cells(1).text = "String2" then

e.item.Cells(3).visible = false
e.item.Cells(4).visible = false

End if

End if

End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Columns, Filter & Copy Visable to new wrkbk dursta Excel VBA 1 June 4th, 2007 06:17 AM
ASP.NET Datagrid Autogenaratedcolunm Hide Problem sibajibasak .NET Framework 2.0 3 March 2nd, 2005 10:59 PM
Resize and Hide columns in WEB FORM Datagrid? Ron Howerton Classic ASP Basics 5 April 30th, 2004 07:42 AM
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.