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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:17:08+00:00 2026-05-26T02:17:08+00:00

I have no problem creating sql queries where the value for the parameter comes

  • 0

I have no problem creating sql queries where the value for the parameter comes from a control (dropdownlist). However, how do i adjust my query and set up the dropdown list, so that when page first loads, no value is used as a parameter? For instance, say i was to create a gridview that filters by state. The dropdownlist contains a listing of states to filter by. However, lets say i wanted to include a value called “All States”, and have it be the default, and the gridfview show all states?

  • 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-26T02:17:09+00:00Added an answer on May 26, 2026 at 2:17 am

    Since you’re using the SqlDataSource control; I think your best bet is to create a stored procedure and use that. You can then set a “default” parameter value, and set that to something like “All”. Then your stored procedure can do the logic behind figuring out how to craft the “WHERE”.

    AFAIK the SqlDataSource doesn’t have the ability to change or omit parameters.

    EDIT

    There is more information here about setting default values for the parameters. This is pretty straight forward.

    As far as your stored procedure, you would want it to accept a parameter, probably a string, and it would then decide whether or not to use a WHERE clause, similar to this:

    CREATE PROCEDURE GetStatesFromParameter
        -- Add the parameters for the stored procedure here
        @state nvarchar(MAX) = 'All'
    AS
    BEGIN
        -- SET NOCOUNT ON added to prevent extra result sets from
        -- interfering with SELECT statements.
        SET NOCOUNT ON;
    
        IF @state = 'All'
        BEGIN
            SELECT * FROM States
        END
        ELSE
        BEGIN
            SELECT * FROM States WHERE Name = @state
        END
    END
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a problem wherein we keep having complex SQL queries go
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
Currently, my entire website does updating from SQL parameterized queries. It works, we've had
i have 2 tables(result of two separate SQL queries and this result will be
I am having a problem with creating my database in SQL Server Compact I
I'm working on creating a development database for my boss. I have the SQL
In the designer I get this error: Error Creating Control: Object Reference Not Set
I have a problem creating a for-loop using Javascript. It seems everyting is fine
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names

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.