Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
Reply With Quote
  #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
Default

Hi,

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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.