Checking row count from ObjectDataSource with Filtering

Posted on 2009-02-22
Last Modified: 2012-05-06
I have a lot of asp Labels acting as section headers on my page which I need to hide if there are no records in the ObjectDataSource.

This has been working fine with the code below but now that I have implemented filtering the code is still counting rows even though there aren't actually any displayed.

Can you suggest a way to take into consideration the filtering when counting the rows?
protected void ShowHidePanels()


        System.Collections.IEnumerable ie = GridViewDS.Select();

        int Count = ((System.Data.DataView)(ie)).Table.Rows.Count;

        if (Count > 0)


            IncomingReturnsHeaderPanel.Visible = true;

            IncomingReturnsWrap.Visible = true;

            ShowDetailsMessage.Text = "<br>Select a Return to View Details";




            ShowDetailsMessage.Visible = true;

            ReturnDetailsView.Visible = false;

            CustomerDetailsView.Visible = false;

            FaultDetailsView.Visible = false;

            ReturnDetailsHeaderPanel.Visible = false;

            FaultDetailsHeaderPanel.Visible = false;

            CustomerDetailsHeaderPanel.Visible = false;

            ReturnDetailsWrap.Visible = false;

            FaultDetailsWrap.Visible = false;

            CustomerDetailsWrap.Visible = false;

            IncomingReturnsHeaderPanel.Visible = false;

            ShowDetailsMessage.Text = "<br>There are no incoming returns at present.";

///Im setting the Filtering like this...

GridViewDS.FilterExpression = "DOR >= '" + DateFromTextBox.Text + "' and DOR <= '" + DateToTextBox.Text + "'";

/// I then call the method above once the filterexpression has been added to try to hide all the labels if there are now no records after filtering.

Open in new window

Question by:andrewmilner
    LVL 10

    Accepted Solution

    Try this

    Ref: (using compute with count)

    //instead of

    Open in new window


    Author Closing Comment

    BINGO!.  Thank you very much!.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    HTML table 7 40
    SQL QUERY to Table question 32 60
    Can't create users table in existing DB 16 53
    IIs block files web.config 6 54
    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now