views:

5

answers:

0

Hi, I need to be able to change a Boolean variable if a datasource actually retrieves any data, so gridviews/detailsviews aren't displayed. I've placed all the data inside a PlaceHolder tag which is by default not visible.

But using the SqlDataSource1_Selected method, it doesn't actually change the boolean variable - why is this? Here is my code:

    protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
        if (e.AffectedRows == 0)
        {
            displayData = false;
        }
        else
        {
            displayData = true;
        }


    }

And this is a snippet from my datasource in ASP to show it is indeed linking to the method:

onselected="SqlDataSource1_Selected"