Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6106981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:08:20+00:00 2026-05-23T14:08:20+00:00

I have a sqldatasource, in select command i have @status parameter. The parameter take

  • 0

I have a sqldatasource, in select command i have @status parameter. The parameter take the value from the textbox at runtime.

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [project_details] WHERE ([status] = @status)" 
            FilterExpression="title='{4}'" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
            EnableCaching="True">
 <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="status" PropertyName="Text" ConvertEmptyStringToNull="false"
                    Type="String" />
            </SelectParameters>

        </asp:SqlDataSource>

my problem is that when i run the page without entring the parameter in text box sqldatasource is not returing any row.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:08:21+00:00Added an answer on May 23, 2026 at 2:08 pm

    Looking at the documentation on MSDN, you have to alter how you have setup the SqlDataSource.

    Try this:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [project_details]" 
            FilterExpression="title='{0}'" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
            EnableCaching="True">
        <FilterParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="status" PropertyName="Text" ConvertEmptyStringToNull="false" Type="String" />
        </FilterParameters>
    </asp:SqlDataSource>
    

    I have removed the Where clause from the query as this will be applied by the filter expression. Also, I have changed the filter expression from title='{4}' to title='{0}'. The documentation states that the number is a placeholder to an item in the FilterParameters collection.

    Updated
    I have also changed the SelectParameters to FilterParameters

    Update 2

    I have created a working example to finish of this answer. This will filter the Title column using the text from the text box. If this text box is empty it will return all the rows from the table (a scary thought but OK for this example). It is querying the AdventureWorks database for which I set a connection string called AWorks.

    <asp:SqlDataSource ID="SqlDataSource1"
        ConnectionString="<%$ ConnectionStrings:AWorks %>"
        SelectCommand="SELECT ContactId, Title, FirstName, LastName FROM Person.Contact"
        FilterExpression="Title='{0}'"
        runat="server">
     <FilterParameters>
        <asp:ControlParameter Name="Title" ControlID="txtTitle" PropertyName="Text" />
     </FilterParameters> 
    </asp:SqlDataSource>
    
    <asp:TextBox runat="server" Id="txtTitle"></asp:TextBox>
    <asp:Button runat="server" UseSubmitBehavior="true" Text="Submit" />
    
    <asp:GridView 
        DataSourceID="SqlDataSource1"
        AutoGenerateColumns="false"
        runat="server">
    <Columns>
        <asp:BoundField Visible="false" DataField="ContactId"></asp:BoundField>
        <asp:BoundField Visible="true" DataField="Title"></asp:BoundField>
        <asp:BoundField Visible="true" DataField="FirstName"></asp:BoundField>
        <asp:BoundField Visible="true" DataField="LastName"></asp:BoundField>
    </Columns>
    </asp:GridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dropdownlist, whose datasource is from SQL server. <asp:DropDownList ID=State runat=server DataSourceID=SqlDataSource1
I have the following SQLDataSource : <asp:SqlDataSource ID=topicSource runat=server ConnectionString=<%$ ConnectionStrings SelectCommandType=Text SelectCommand=SELECT *
I have a SqlDataSource SelectCommand on my .aspx page. <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:MyConnectionString
I have the following itemTemplate in my datalist <ItemTemplate> <asp:LinkButton ID=LinkButton1 CommandName=Select autopostback=True runat=server>'<%#
On an ASP.NET page, I have a SqlDataSource configured with the following SELECT command:
I have an SqlDataSource with following command: SELECT * FROM [vw_aspnet_MembershipUsers] WHERE ([UserId] =
I have FormView in my page markup: <asp:FormView ruanat=server ID=FormView1 DataSourceID=SqlDataSource1 OnDataBinding=FormView1_DataBinding OnDataBound=FormView1_DataBound> <InsertItemTemplate>
I have a sqldatasource connection in whose parameters, the insert parameter is set as
I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I've got a gridview that populates from four tables, and the select command (shown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.