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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:44:02+00:00 2026-05-30T14:44:02+00:00

while configuration sqldatasouce1 IN ASP.NET i used sql statement where sql statement is working

  • 0

while configuration sqldatasouce1 IN ASP.NET i used sql statement where sql statement is working well in Test Query THE statement is as follows

SELECT 
    Name, Gender, Cast, Qualification, Occupation, Country, Age 
FROM  
    Registration 
WHERE 
    (Gender = @gender OR @gender IS NULL) 
    AND (Cast = @cast OR @cast IS NULL) 
    AND (Country = @country OR @country IS NULL) 
    AND (Age >= @Age OR @Age IS NULL) 
    AND (Age <= @Age2 OR @Age2 IS NULL)

in my design view I have 1 dropdownbox for gender 1 for cast 1 textbox to select age from another textbox to but it’s not working when I run the design. It’s working only when I fill all values for parameter.

here is my asp source code

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="PatnerSearch.aspx.vb" 
     Inherits="PatnerSearch" %>

        <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
    namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 90px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 122px">

        <table class="style1">
            <tr>
                <td class="style2">
                    Gender</td>
                <td>
                    <asp:DropDownList ID="ddgender" runat="server" DefaultValue=" " AutoPostBack="True">
                        <asp:ListItem Selected="True"></asp:ListItem>
                        <asp:ListItem>Male</asp:ListItem>
                        <asp:ListItem>Female</asp:ListItem>
                    </asp:DropDownList>
                    </td>
            </tr>
            <tr>
                <td class="style2">
                    Cast</td>
                <td>
                    <asp:DropDownList ID="ddcast" runat="server" DefaultValue=" " AutoPostBack="True">
                        <asp:ListItem Selected="True"></asp:ListItem>
                        <asp:ListItem>Sunni</asp:ListItem>
                        <asp:ListItem>Shai</asp:ListItem>
                        <asp:ListItem>Madhvi</asp:ListItem>
                        <asp:ListItem>Mamens</asp:ListItem>
                        <asp:ListItem>Other</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Age</td>
                <td>
                    From:
                    <asp:TextBox ID="txtfrom" runat="server"></asp:TextBox>
&nbsp;To:
                    <asp:TextBox ID="txtto" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Country</td>
                <td>
                    <asp:DropDownList ID="ddcountries" runat="server" DefaultValue=" " AutoPostBack="True">
                        <asp:ListItem Selected="True"></asp:ListItem>
                        <asp:ListItem>Afghanistan</asp:ListItem>
                        <asp:ListItem>Akrotiri</asp:ListItem>
                        <asp:ListItem>Albania</asp:ListItem>
                        <asp:ListItem>Algeria</asp:ListItem>
                        <asp:ListItem>American Samoa</asp:ListItem>
                        <asp:ListItem>Andorra</asp:ListItem>
                        <asp:ListItem>Angola</asp:ListItem>
                        <asp:ListItem>Anguilla</asp:ListItem>
                        <asp:ListItem>Antarctica</asp:ListItem>
                        <asp:ListItem>Antigua and Barbuda</asp:ListItem>
                        <asp:ListItem>Argentina</asp:ListItem>
                        <asp:ListItem>Armenia</asp:ListItem>
                        <asp:ListItem>Aruba</asp:ListItem>
                        <asp:ListItem>Ashmore and Cartier Islands</asp:ListItem>
                        <asp:ListItem>Australia</asp:ListItem>
                        <asp:ListItem>Austria</asp:ListItem>
                        <asp:ListItem>Azerbaijan</asp:ListItem>
                        <asp:ListItem>Bahamas, The</asp:ListItem>
                        <asp:ListItem>Bahrain</asp:ListItem>
                        <asp:ListItem>Bangladesh</asp:ListItem>
                        <asp:ListItem>Barbados</asp:ListItem>
                        <asp:ListItem>Bassas da India</asp:ListItem>
                        <asp:ListItem>Belarus</asp:ListItem>
                        <asp:ListItem>Belgium</asp:ListItem>
                        <asp:ListItem>Belize</asp:ListItem>
                        <asp:ListItem>Benin</asp:ListItem>
                        <asp:ListItem>Bermuda</asp:ListItem>
                        <asp:ListItem>Bhutan</asp:ListItem>
                        <asp:ListItem>Bolivia</asp:ListItem>
                        <asp:ListItem>Bosnia and Herzegovina</asp:ListItem>
                        <asp:ListItem>Botswana</asp:ListItem>
                        <asp:ListItem>Bouvet Island</asp:ListItem>
                        <asp:ListItem>Brazil</asp:ListItem>
                        <asp:ListItem>British Indian Ocean Territory</asp:ListItem>
                        <asp:ListItem>British Virgin Islands</asp:ListItem>
                        <asp:ListItem>Brunei</asp:ListItem>
                        <asp:ListItem>Bulgaria</asp:ListItem>
                        <asp:ListItem>Burkina Faso</asp:ListItem>
                        <asp:ListItem>Burma</asp:ListItem>
                        <asp:ListItem>Burundi</asp:ListItem>
                        <asp:ListItem>Cambodia</asp:ListItem>
                        <asp:ListItem>Cameroon</asp:ListItem>
                        <asp:ListItem>Canada</asp:ListItem>
                        <asp:ListItem>Cape Verde</asp:ListItem>
                        <asp:ListItem>Cayman Islands</asp:ListItem>
                        <asp:ListItem>Central African Republic</asp:ListItem>
                        <asp:ListItem>Chad</asp:ListItem>
                        <asp:ListItem>Chile</asp:ListItem>
                        <asp:ListItem>China</asp:ListItem>
                        <asp:ListItem>Christmas Island</asp:ListItem>
                        <asp:ListItem>Clipperton Island</asp:ListItem>
                        <asp:ListItem>Cocos (Keeling) Islands</asp:ListItem>
                        <asp:ListItem>Colombia</asp:ListItem>
                        <asp:ListItem>Comoros</asp:ListItem>
                        <asp:ListItem>Congo, Democratic Republic of the</asp:ListItem>
                        <asp:ListItem>Congo, Republic of the</asp:ListItem>
                        <asp:ListItem>Europe</asp:ListItem>
                        <asp:ListItem>UK</asp:ListItem>
                        <asp:ListItem>USA</asp:ListItem>
                        <asp:ListItem>Germany</asp:ListItem>
                        <asp:ListItem>India</asp:ListItem>
                        <asp:ListItem>Pakistan</asp:ListItem>
                        <asp:ListItem>Bangladesh</asp:ListItem>
                        <asp:ListItem>Srilanka</asp:ListItem>
                        <asp:ListItem>Nepal</asp:ListItem>
                        <asp:ListItem>China</asp:ListItem>
                        <asp:ListItem>Japan</asp:ListItem>
                        <asp:ListItem>UAE</asp:ListItem>
                        <asp:ListItem>KSA</asp:ListItem>
                        <asp:ListItem>South Africa</asp:ListItem>
                        <asp:ListItem>Hong Kong</asp:ListItem>
                        <asp:ListItem>Other</asp:ListItem>
                    </asp:DropDownList>
                    </td>
            </tr>
        </table>
        <asp:Button ID="Button1" runat="server" Text="Search" />
        <br />
        <br />
        <br />
        <br />

    </div>
    <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Gender" HeaderText="Gender" 
                    SortExpression="Gender" />
                <asp:BoundField DataField="Cast" HeaderText="Cast" SortExpression="Cast" />
<asp:BoundField DataField="Qualification" HeaderText="Qualification" 
                    SortExpression="Qualification"></asp:BoundField>
                <asp:BoundField DataField="Occupation" HeaderText="Occupation" 
                    SortExpression="Occupation" />
                <asp:BoundField DataField="Country" HeaderText="Country" 
                    SortExpression="Country" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
            </Columns>
        </asp:GridView>
    <p>
        &nbsp;</p>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Database1ConnectionString %>" 

        SelectCommand="SELECT Name, Gender, Cast, Qualification, Occupation, Country, Age FROM Registration WHERE (Gender = @gender OR @gender IS NULL) AND (Cast = @cast OR @cast IS NULL) AND (Country = @country OR @country IS NULL) AND (Age &gt;= @Age OR @Age IS NULL) AND (Age &lt;= @Age2 OR @Age2 IS NULL)">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddgender" Name="Gender" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="ddcast" Name="Cast" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="ddcountries" Name="country" 
                PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="txtfrom" Name="Age" PropertyName="Text" />
            <asp:ControlParameter ControlID="txtto" Name="Age2" PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>

My button event is as below

Partial Class PatnerSearch
    Inherits System.Web.UI.Page

  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

  End Sub
End Class
  • 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-30T14:44:04+00:00Added an answer on May 30, 2026 at 2:44 pm

    Edit: sorry, I first misunderstood your problem.

    The solution to your problem, however, is simple.

    Just set CancelSelectOnNullParameter on your SqlDataSource to False

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

Sidebar

Related Questions

What are your favorite Git configuration settings which make your life easy while working
While I run my simple Junit test for testing the the Jpa/Dao configuration I
While converting a project that used SlimDX, and therefore has unmanaged code, to .NET
I've been swapping out connectionstrings wholesale wtih xlst for a while thusly <xsl:template match=/configuration/connectionStrings/add[@name='SybaseDB']/@connectionString
What we are looking for is: while compiling the same configuration, say Release|Win32, is
While working in a Java app, I recently needed to assemble a comma-delimited list
While in the final throws of upgrading MS-SQL Server 2005 Express Edition to MS-SQL
{Configuration system failed to initialize} i get this error while trying to run a
This is the configuration file while hosting the service, here i hosted service using
While setting WCF client service configuration, there is an option collection type which defaults

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.