开发者

isPostBack as Query Parameter

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?


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;
    }
}


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

if (!Page.IsPostback){}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜