Hide a datagrid when no results are found

           

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();

            }
kevinsb1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AerosSagaCommented:
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
AerosSagaCommented:
or

if myDataGrid.Items.count = 0 then
  myDataGrid.visible = false
end if
0
riyasjefCommented:
Hi

Try

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

RJ
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

mmarinovCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevinsb1Author Commented:

Thanks all for your help...........
0
mmarinovCommented:
Glad that can help
Regards!
B..M
mmarinov
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.