1

I have a sqldatasource where i have added a simple filter expression just for testing

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                SelectCommand="SELECT * FROM [project_details]" 
                FilterExpression="id=33" 
                ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                EnableCaching="True">

and a grid view in update panel which has datasource as sqldatasouce1 . but on executing this page grid view is showing all the result withour any filtering . please help me i am totally struck here

4
  • :: Datasource mode is already set to "Dataset" Commented Jul 6, 2011 at 11:16
  • Have you checked for typo's? Are you sure you are using the correct SqlDatasourceID? FilterExpression should work just fine. Commented Jul 6, 2011 at 11:42
  • yuo.i have checked like hundred time. Commented Jul 6, 2011 at 11:44
  • i tried doing the way that you told using "where" it is working fine .but there is also one problem if i dont give a parameter value to the Parameter .it is not showing any result.because the user is suppose to add where parameter at runtime. Commented Jul 6, 2011 at 11:51

1 Answer 1

1

If the id is stored in text format then you might want to give single quotes in the expression as shown here:

id='33'

Sign up to request clarification or add additional context in comments.

2 Comments

not working .i think single qoute is for string field only.MSDN You can include parameters in the FilterExpression property. If the parameter is a string or character type, enclose the parameter in single quotation marks. Quotation marks are not required, if the parameter is a numeric type. The FilterParameters collection contains the parameters that are evaluated for the placeholders that are found in the FilterExpression property.
That's why I wrote "If"...I didnt know what format your field was in and I gave you a sample solution in case it was string.

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.