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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:23:29+00:00 2026-05-21T17:23:29+00:00

I have been trying to pass selected data from two dropdownlist (page1.aspx) to (page2.aspx)

  • 0

I have been trying to pass selected data from two dropdownlist (page1.aspx) to (page2.aspx) I am not having any luck as it seems the data is not being passed when selected. Please help, this doesn’t seem that difficult, but I can not get it work. On (page2.aspx) the data from the dropdownlists will be passed to a stored procedure and all results will be in a gridview.

Here is my code:

Page1.aspx

<asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="ST_Code" DataValueField="ST_Code" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnection %>"SelectCommand="SELECT [ST_Code] FROM [State]">
</asp:SqlDataSource> City:  <asp:DropDownList ID="ddlCity" runat="server" DataSourceID="SqlDataSource2" DataTextField="RS_City" DataValueField="RS_City" />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnection %>"SelectCommand="ListbyStateSPROC"SelectCommandType="StoredProcedure">`
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlState" Name="State" PropertyName="SelectedValue"  Type="String" />       
        </SelectParameters>
</asp:SqlDataSource>

       <asp:Button ID="Submit" runat="server" Text="Submit" />
    &nbsp;

</asp:Content>

Page1.aspx.vb

Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls.DataGrid
Imports System.Web.UI.WebControls.DropDownList


Partial Public Class LiveEventSearch
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Public Sub ddlState_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SqlDataSource2.SelectParameters.Clear()
        SqlDataSource2.SelectParameters.Add(New Parameter("@State", DbType.String, ddlState.SelectedValue))
        ddlCity.DataBind()


    End Sub

    Protected Sub ddlCity_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCity.SelectedIndexChanged

    End Sub


    Protected Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click

    End Sub
End Class

Page2.aspx

 <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1" Style="z-index: 100; left: 324px; position: absolute;
        top: 226px">
        <Columns>
            <asp:BoundField DataField="Code" HeaderText="Code" ReadOnly="True" SortExpression="R_Code" />
            <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="R_Name" />
            <asp:BoundField DataField="Number" HeaderText="Number" ReadOnly="True" SortExpression="RS_Number" />
            <asp:BoundField DataField="Addr_1" HeaderText="Addr_1" ReadOnly="True" SortExpression="RS_Addr_1" />
            <asp:BoundField DataField="City" HeaderText="City" ReadOnly="True" SortExpression="RS_City" />
            <asp:BoundField DataField="State" HeaderText="State" ReadOnly="True" SortExpression="RS_State" />
            <asp:BoundField DataField="RS_Zip" HeaderText="RS_Zip" ReadOnly="True" SortExpression="RS_Zip" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbConnection %>"
        SelectCommand="ListbyCityStSPROC" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:QueryStringParameter Name="City" QueryStringField="RS_City" Type="String" />
            <asp:QueryStringParameter Name="State" QueryStringField="ST_Code" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

</asp:Content>
  • 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-21T17:23:30+00:00Added an answer on May 21, 2026 at 5:23 pm

    Effectively each page in an ASP.NET application is like a single app in itself, things don’t last across pages, so you either need to implement a class that keeps hold of your SQLDataSource so can call it across pages or you need to implement some way to copy the data across the pages.

    You could also use the FindControl function to find the SQLDataSource across pages:

    SqlDataSource sql = (SqlDataSource)Page.Master.Findcontrol("SqlDataSource1");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to optimize the two following nested loops: def startbars(query_name, commodity_name):
i have been using an actionListener to pass text from numerous TextFields into a
I have been trying this for so long, but was not able to implement
I have been trying in vain for almost two weeks now to generate a
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to find a really fast way to parse yyyy-mm-dd [hh:mm:ss]
I have been trying to determine a best case solution for registering a COM
I have been trying to work my way through Project Euler, and have noticed
I have been trying to get around this error for a day now and
I have been trying to explain the difference between switch statements and pattern matching(F#)

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.