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

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

Checking row count from ObjectDataSource with Filtering

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

1 Solution
Try this

http://forums.asp.net/t/940679.aspx (using compute with count)

//instead of

Open in new window

andrewmilnerAuthor Commented:
BINGO!.  Thank you very much!.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now