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

  • Home
  • SEARCH
  • 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 8271273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:47:50+00:00 2026-06-08T06:47:50+00:00

I am using querystring for passing a value which is used to select the

  • 0

I am using querystring for passing a value which is used to select the subscription category (variable name subno) on second page.

Based on the subscription category (subno is specified as integer in sql server as part of table categories) second page is invoked using the following URL-

http://localhost:53175/v1/ProductsList.aspx?subno=1
or
http://localhost:53175/v1/ProductsList.aspx?subno=2

In the second page subno is used to query the items based on subno passed.

<asp:SqlDataSource ID="subscription" runat="server"  
        ConnectionString="<%$ ConnectionStrings:aimnbde3ConnectionString %>" 

        SelectCommand="SELECT [subscription] FROM [subscription] WHERE ([subno] = @subno)">
    <SelectParameters>
        <asp:QueryStringParameter Name="subno" QueryStringField="subno" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

This code works well if category(varibale subno) is passed.
In case second page is called directly like

http://localhost:53175/v1/ProductsList.aspx

Then value of subno is interpreted as 0. Do we have a way to change the query(SelectCommand=”SELECT [subscription] FROM [subscription] ) based on value of subno ?

Or please suggest the right way to handle the case where subno is not passed

Editing –

Sorry for missing an important part of question-

When http://localhost:53175/v1/ProductsList.aspx is accessing i want to display all the products so the query will be

SELECT [subscription] FROM [subscription]

and in case a value is passed query will be

SELECT [subscription] FROM [subscription] WHERE ([subno] = @subno)
  • 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-08T06:47:51+00:00Added an answer on June 8, 2026 at 6:47 am

    I would change the query to this:

    SELECT [subscription] FROM [subscription] WHERE (@subno is null or [subno] = @subno)
    

    and then add the following to the parameter

    ConvertEmptyStringToNull = "TRUE"
    

    and the following to the SQLDataSource

    CancelSelectOnNullParameter = "FALSE"
    

    So your code would look like this:

    <asp:SqlDataSource ID="subscription" runat="server" CancelSelectOnNullParameter="false" 
            ConnectionString="<%$ ConnectionStrings:aimnbde3ConnectionString %>" 
    
            SelectCommand="SELECT [subscription] FROM [subscription] WHERE (@subno is null or [subno] = @subno)">
        <SelectParameters>
            <asp:QueryStringParameter Name="subno" QueryStringField="subno" Type="Int32" ConvertEmptyStringToNull = "true"/>
        </SelectParameters>
    </asp:SqlDataSource>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm unclear on the proper format for passing a QueryString Value using FlashVars, this
I am using request.querystring just to access a parameter which I am passing from
I am using a generateimage.aspx page which is used as an image source for
Looking for advice on passing variables from page to page without using QueryString. The
I Need to make a webpage. asp.net this webpage recieve parameter by using Request.Querystring
I believe I am using the correct queryString params for jdbc connection jdbc:mysql://localhost:3306/databasename?useUnicode=true&characterEncoding=utf8&noAccessToProcedureBodies=true My
I have a SqlDependency set up using the following query: string sql = "SELECT
using a c# asp.net page, building a SQL query string to run against an
Using SQL Server 2008 R2 we are looking for a way to select the
I'm storing some value in an asp.net session on the first page. On the

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.