User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,495 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,693 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2019 | Replies: 3 | Solved
Reply
Join Date: Aug 2007
Posts: 23
Reputation: culebrin is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
culebrin culebrin is offline Offline
Newbie Poster

Hide Button when DataView is empty

  #1  
Sep 22nd, 2007
Hi hi!

Just that, I want to hide a asp:button when a asp:dataview is empty and show it when it has records...

Any Ideas?

Omar
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: England
Posts: 156
Reputation: ptaylor965 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Hide Button when DataView is empty

  #2  
Sep 23rd, 2007
for Dataview use
If dataview.count = 0 then
button1.visible = False
else
button1.visible = True
End If
or
for datatables use
If datatable.rows.count = 0 then 
button1.visible = False
else
button1.visible = True
End If
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote  
Join Date: Aug 2007
Posts: 23
Reputation: culebrin is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
culebrin culebrin is offline Offline
Newbie Poster

Re: Hide Button when DataView is empty

  #3  
Sep 23rd, 2007
Thanks for your reply ptaylor965, !!

Well, first of all, I made a mistake about the component, Its a gridview; second of all, on which event do I put these codes? consider that my gridview its binded by design with a objectdatasource, and I can't change that.

Thanks again!!

Omar

Originally Posted by ptaylor965 View Post
for Dataview use
If dataview.count = 0 then
button1.visible = False
else
button1.visible = True
End If
or
for datatables use
If datatable.rows.count = 0 then 
button1.visible = False
else
button1.visible = True
End If
Reply With Quote  
Join Date: Oct 2006
Location: England
Posts: 156
Reputation: ptaylor965 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Hide Button when DataView is empty

  #4  
Sep 23rd, 2007
For DataGrids use
If datagrid.rows.count = 0 then 
button1.visible = False
else
button1.visible = True
End If
I would place this code on form_load and on any buttons or events that fill/refresh the datagrid
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC