944,184 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 5319
  • ASP.NET RSS
Sep 22nd, 2007
0

Hide Button when DataView is empty

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Sep 23rd, 2007
0

Re: Hide Button when DataView is empty

for Dataview use
ASP.NET Syntax (Toggle Plain Text)
  1. If dataview.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. End If
or
for datatables use
ASP.NET Syntax (Toggle Plain Text)
  1. If datatable.rows.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. End If
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Sep 23rd, 2007
0

Re: Hide Button when DataView is empty

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

Click to Expand / Collapse  Quote originally posted by ptaylor965 ...
for Dataview use
ASP.NET Syntax (Toggle Plain Text)
  1. If dataview.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. End If
or
for datatables use
ASP.NET Syntax (Toggle Plain Text)
  1. If datatable.rows.count = 0 then
  2. button1.visible = False
  3. else
  4. button1.visible = True
  5. End If
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Sep 23rd, 2007
0

Re: Hide Button when DataView is empty

For DataGrids use
ASP.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Comment tag ASP.NET
Next Thread in ASP.NET Forum Timeline: Session variables





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC