Hide Button when DataView is empty

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2007
Posts: 57
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

Hide Button when DataView is empty

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Hide Button when DataView is empty

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

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 57
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

Re: Hide Button when DataView is empty

 
0
  #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
  1. If dataview.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. End If
or
for datatables use
  1. If datatable.rows.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. End If
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Hide Button when DataView is empty

 
0
  #4
Sep 23rd, 2007
For DataGrids use
  1. If datagrid.rows.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. 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 Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 3537 | Replies: 3
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC