views:

9

answers:

0

Hi, I am using a GridView and I require the user to be able to filter using 2 controls. One simply filters the type of row - there is a column called action, and the user selects one of the distinct values from the database in a dropdown box, and the gridview only displays the rows with that value in the action column. On it's own this works perfect.

But I am also adding a textbox where the user can type in an ID of either the 'itemID', or the 'parentID'. This works fine even with the previous control.

Problem is, the dropdown box does not work when the textbox is empty (i.e. all ID's are being shown). If I choose a value and click Submit, it just doesn't do anything. Now if I am filtering by ID and then choose a value from the dropdown box, it works perfect.

Here is my filter expression and parameters of the datasource:

      <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="cleared for privacy"
        SelectCommand="SELECT * FROM [Audit] WHERE ([source] = @source)" FilterExpression="action like '{0}%' and (itemID like '{1}' or parentID like '{1}')">
        <SelectParameters>
            <asp:Parameter DefaultValue="LOGISTICS" Name="source" Type="String" />
        </SelectParameters>
        <FilterParameters>
            <asp:ControlParameter Name="action" ControlID="DropDownList1" PropertyName="SelectedValue" />
            <asp:ControlParameter Name="legorinvid" ControlID="txtFilter" PropertyName="Text" />
        </FilterParameters>
    </asp:SqlDataSource>