Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Hide a datagrid when no results are found

Posted on 2004-11-09
6
Medium Priority
?
347 Views
Last Modified: 2008-02-01
           

I have two datagrids one on top of the other, and when you enable and disable and item it displays either  on top as active or on the bottom as disabled, i want the disabled datagrid not to show up, right now it shows the header, but i want it removed completly.   How would i disable the bottom datagrid when nothing is disabled? See code for more info.


private void BindGrids()
            {
                  grdActivePages.DataSource = Section.GetPagesBySectionID(sectionID,1);
                  grdActivePages.DataMember = "ID";
                  grdActivePages.DataBind();
                  
                  grdDisabledPages.DataSource = Section.GetPagesBySectionID(sectionID,0);
                  grdDisabledPages.DataMember = "ID";
                  grdDisabledPages.DataBind();

            }
0
Comment
Question by:kevinsb1
6 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12536654
check your dataset before you bind using this:
 If ds.Tables.Count > 0 And ds.Tables(0).Rows.Count > 0 Then
     lblNoResults.Visible = False
Else
     lblNoResults.Visible = True
End If

Aeros
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12536664
or

if myDataGrid.Items.count = 0 then
  myDataGrid.visible = false
end if
0
 
LVL 9

Expert Comment

by:riyasjef
ID: 12536700
Hi

Try

grdDisabledPages.Visible="False";  to hide the whole grid

RJ
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Accepted Solution

by:
mmarinov earned 2000 total points
ID: 12539124
Hi kevinsb1,

i assume that
Section.GetPagesBySectionID(sectionID,1) returns DataSet ( it will be the same with a datareader ) and suggest you to return null if there are no records returned
if the DataSource is null then the complete datagrid will not be shown on the page ( including the header )

Regards!
B..M
mmarinov
0
 

Author Comment

by:kevinsb1
ID: 12548730

Thanks all for your help...........
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12548779
Glad that can help
Regards!
B..M
mmarinov
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question