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 7932999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:11:30+00:00 2026-06-03T21:11:30+00:00

I have a gridview with sqldatasource, etc. For the grid, I also have a

  • 0

I have a gridview with sqldatasource, etc. For the grid, I also have
a search textbox. If the user needs to filter the records, I want to
dynamically adjust the SELECT statement for the SqlDataSource using a sql procedure with a parametre can take the value from the textbox . I like
all the automatic capabilities for paging, sorting, etc., so I don’t
want to just bind the old way.

Any clues?

thanks,

 <form id="form1" runat="server">
    <div>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            SelectCommand="SelectCategorie" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="CategorieName" 
                    PropertyName="Text" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            SelectCommand="SELECT [ProductName], [ProductID] FROM [Alphabetical list of products]">
        </asp:SqlDataSource>
        <br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button3" runat="server" Text="Button" />
        <br />
        <br />
        <asp:DropDownList ID="DropDownList1" runat="server" 
            DataSourceID="SqlDataSource3" DataTextField="ProductName" 
            DataValueField="ProductName">
        </asp:DropDownList>
        <br />
        <br />
                <asp:Button ID="Button2" runat="server" Text="Change the datasource" />
        <br />
        <br />
                <asp:GridView ID="GridView1" runat="server" 
                    DataKeyNames="ProductID" DataSourceID="SqlDataSource1">
                    <Columns>
                        <asp:BoundField DataField="ProductID" HeaderText="ProductID" 
                            InsertVisible="False" ReadOnly="True" SortExpression="ProductID" 
                            DataFormatString="[Yassine {0}]" />
                        <asp:BoundField DataField="ProductName" HeaderText="ProductName" 
                            SortExpression="ProductName" />
                        <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" 
                            SortExpression="SupplierID" />
                        <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
                            SortExpression="CategoryID" />
                        <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" 
                            SortExpression="CategoryName" />
                        <asp:BoundField DataField="Description" HeaderText="Description" 
                            SortExpression="Description" />
                        <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" 
                            SortExpression="QuantityPerUnit" />
                        <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" 
                            SortExpression="UnitPrice" />
                        <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" 
                            SortExpression="UnitsInStock" />
                        <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" 
                            SortExpression="UnitsOnOrder" />
                        <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" 
                            SortExpression="ReorderLevel" />
                        <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" 
                            SortExpression="Discontinued" />
                    </Columns>
                </asp:GridView>
        <br />
        <br />

    </div>
    </form>

and the code behind the scene :

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        SqlDataSource1.SelectCommand = "SelectCategorieParDescription"
        SqlDataSource1.SelectParameters.Add("@ProductName", DropDownList1.DataValueField)
    End Sub
End Class

and this is the erreur i got :

Procedure or function SelectCategorieParDescription has too many arguments specified

  • 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-06-03T21:11:32+00:00Added an answer on June 3, 2026 at 9:11 pm

    We use a similar approach on what you want to do. The hard way is the following (you can see an article about this here:

    1. Create a grammar for your search syntax
    2. Create a parser for that grammar
    3. Create an interpreter along with the parser that will convert your search syntax into a SQL (the WHERE part)
    4. Create a stored procedure that can take this whereSql string and concatenate with the complete query and call EXEC(@sqlQuery)

    However, all this might take you a while, another option would be to restraint your search capabilities to single strings. Example:

    1. Say you have your query with the possibility to search on 2 columns: name, socsecNumber
    2. Whenever you read the string john you convert this to:
      name like ‘%john%’ or (convert socsecNumber to string) like ‘%john%’
    3. Up to you to use the % all the time or maybe only when the user’s input is something like: joh*
    4. The stored procedure receiving the where query is a little bit like this:

      ALTER PROCEDURE [dbo].[usp_SearchForObjectsForDashboard]
          @searchTerm as varchar(250)
      BEGIN
          ...
          SET @sql = 'SELECT ...
              ...
              WHERE someConditionOfYourOwn = whatever
               AND ' + @searchTerm
      
          EXEC(@sql) 
      END
      

    Hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a gridview automaticly connecting with sqldatasource1, etc. For the grid, I also
I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I have a SqlDataSource and a GridView. What I want to do is, while
I want to conditionally call update statement on sqldatasource. I have a gridview and
I have GridView with connected SqlDataSource and I want cancel updating row when my
Have a gridview control which will show X amount of rows. I want to
I have a GridView and SqlDataSource for it. SelectCommand is something like SELECT *
I have a GridView with an Update button. I want to update a field
I have gridview in my asp.net page which is bound to sqldatasource. when i
I have a GridView in ASP.net which is filled from an SqlDataSource. one of

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.