-2

This is my sqldatasource with filter expression

   <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    SelectCommand="SELECT [id], [title], [client], [projectmanager], [project_scope], [project_materials], [project_gating], [project_cavities], [project_file], [project_otherdetails], [priority], [commodity], [status], [start_date], [end_date] FROM [project_details]" 
                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                    EnableCaching="True" CacheDuration="1000" 
FilterExpression="title= '{2}'">



 <FilterParameters>
                    <asp:ControlParameter ControlID="DropDownList1" Name="mainsearch" 
                        PropertyName="SelectedItem.Value" />
                    <asp:ControlParameter ControlID="TextBox2" Name="start_date" 
                        PropertyName="Text" />
                    <asp:ControlParameter ControlID="TextBox3" Name="end_date" 
                        PropertyName="Text" />
    <asp:ControlParameter   

                                  </FilterParameters>



    </asp:SqlDataSource>

when i enter the value in Textbox2 it is not working what might be the problem

3
  • possible duplicate of Filter expression in Sqldatasouce Commented Jul 6, 2011 at 13:47
  • 2
    Please don't ask the same questions again. Edit your first question. Commented Jul 6, 2011 at 13:48
  • sorrry will do in future.do you have any solution for this question Commented Jul 6, 2011 at 13:50

1 Answer 1

1

Because you set the ControlID="TextBox1" in your SQL DataSource SelectParameters, but you are setting the value in Textbox2. You have to change it to <asp:ControlParameter ControlID="TextBox2"

<asp:ControlParameter ControlID="TextBox2" DefaultValue="%" Name="title" 
            PropertyName="Text" Type="String" />

Edit: Following your comments, you want to clear the Where Clause. You can do like...

protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    SqlDataSource1.SelectParameters.Clear(); // First Clear the Selected parameters
    SqlDataSource1.SelectCommand = "SELECT [id], [title], [client], [projectmanager], [project_scope], [project_materials], [project_gating], [project_cavities], [project_file], [project_otherdetails], [priority], [commodity], [status], [start_date], [end_date] FROM [project_details]";
}
Sign up to request clarification or add additional context in comments.

5 Comments

select parameter is not related to filter parameter .the select parameter is for where statement
I am talking for where statement.
but my question is about filter expression .remove the where statement from the code.after that it also not working .
You want to remove filteration expression or Where Clause from your query ?
filter expression sucks now i am working with where clause to solve the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.