views:

52

answers:

2

I created an ASPX page with search controls to the left bound as controls for an AccessDataSource.

I want the data grid to be blank on the first calling of the page, but show the results for subsequent page loads.

I plan to achieve this by putting [pFirstRun] = False as my first WHERE condition with the parameter pFirstRun tied to the value isPostBack. How do I achieve this?

Alternatively, is there a better way to achieve this goal?

A: 

You can use the OnSelecting event of your datasource and so something like this for your code infront:

<asp:AccessDataSource ID="AccessDataSource1" runat="server" OnSelecting="AccessDataSource1_Selecting"/>

And something like this in your code-behind:

protected void AccessDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    if (!IsPostBack)
    {
       e.Cancel = true;
    }
}
BritishDeveloper
A: 

you could put the code where you do the databind() on the datagrid within a

if (!Page.IsPostback){}
derek
if the accessdatasource is defined in the code infront you don't need to call databind() so this wont help
BritishDeveloper