J
JenHu
In my restaurant.aspx, I have a 2 dropdownlists (ddlState, ddlCity)
and a button (btnFindRestaurants). The 2 dropdownlist has the first
item as "--Choose--"
After user selected a state and a city and clicked the
btnfindrestaruants button, it should redirect to storelist.aspx page
by using querystrings and list all the restaurants belongs to the
selected State and city.
However, after user selected the state and city, and clicked the
button, the querystring only carries State, I found city is passed
the value "--Choose--" at runtime ( City =
Request.QueryString("City")) but city is picked by user other than
the "--Choose--".
Here is my code, can someone please tell me why I can't get the
selecte value from the City dropdownlist? Thank you.
In restaurant.aspx
------------------------------------
Private Sub btnFindRestaurants_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnFindRestaurants.Click
Response.Redirect("storelist.aspx?City=" + ddlCity.SelectedItem.Text +
"&State=" + ddlState.SelectedItem.Text, True)
End Sub
------------------------------------
In storelist.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim State As String
Dim City As String
Dim ds As DataSet
Dim dr As SqlDataReader
State = Request.QueryString("State")
City = Request.QueryString("City")
conDWDb.Open()
Dim cmdCountStores As New SqlCommand
Dim dtrCountStores As SqlDataReader
With cmdCountStores
.Connection = conDWDb
.CommandText = "Select Count(*) As CountStores from store_table where
co_code=1 and store_mgr is not null and State=@State and City=@City"
.Parameters.Add("@State", SqlDbType.Char).Value = State
.Parameters.Add("@City", SqlDbType.Char).Value = City
End With
dtrCountStores = cmdCountStores.ExecuteReader
dtrCountStores.Read()
lblnumber.Text = dtrCountStores("CountStores")
dtrCountStores.Close()
conDWDb.Close()
End If
End Sub
and a button (btnFindRestaurants). The 2 dropdownlist has the first
item as "--Choose--"
After user selected a state and a city and clicked the
btnfindrestaruants button, it should redirect to storelist.aspx page
by using querystrings and list all the restaurants belongs to the
selected State and city.
However, after user selected the state and city, and clicked the
button, the querystring only carries State, I found city is passed
the value "--Choose--" at runtime ( City =
Request.QueryString("City")) but city is picked by user other than
the "--Choose--".
Here is my code, can someone please tell me why I can't get the
selecte value from the City dropdownlist? Thank you.
In restaurant.aspx
------------------------------------
Private Sub btnFindRestaurants_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnFindRestaurants.Click
Response.Redirect("storelist.aspx?City=" + ddlCity.SelectedItem.Text +
"&State=" + ddlState.SelectedItem.Text, True)
End Sub
------------------------------------
In storelist.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim State As String
Dim City As String
Dim ds As DataSet
Dim dr As SqlDataReader
State = Request.QueryString("State")
City = Request.QueryString("City")
conDWDb.Open()
Dim cmdCountStores As New SqlCommand
Dim dtrCountStores As SqlDataReader
With cmdCountStores
.Connection = conDWDb
.CommandText = "Select Count(*) As CountStores from store_table where
co_code=1 and store_mgr is not null and State=@State and City=@City"
.Parameters.Add("@State", SqlDbType.Char).Value = State
.Parameters.Add("@City", SqlDbType.Char).Value = City
End With
dtrCountStores = cmdCountStores.ExecuteReader
dtrCountStores.Read()
lblnumber.Text = dtrCountStores("CountStores")
dtrCountStores.Close()
conDWDb.Close()
End If
End Sub