开发者

clearing sqldatasource filterexpressions

I have a gridview that is being populated with data from a sqldatasource. I'm using FilterExpressions with a text box to provide a search like function to filter the gridview results. My problem is the only way to "clear" the filtered results is to search again with the text box empty. Not very user-friendly. What I'm trying to do is have a clear开发者_如何学运维 button that clears the filters. Here is what I have, but it is not working. When I click on the button it does nothing.

<asp:Button ID="btnClear" runat="server" onclick="btnClear_Click" Text="Clear" />


protected void btnClear_Click(object sender, EventArgs e)
    {
        SqlDataSource1.FilterParameters.Clear();
        SqlDataSource1.FilterExpression = string.empty;
        gvReporting.DataBind();
    }


SqlDataSource1.FilterExpression = null;

Got it to work using above...


try doing what the function will do if the text-box is empty on the button click handler, like:

SqlDataSource1.FilterExpression = "name like %"

PS:- Haven't worked with SqlDataSource but from the information I am able to gather this should work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜