Hoping someone can help end the misery.
I have a an aspx page that displays customer contact info at the top followed by a databound dropdownlist that contains a list of products the customer has purchased. The bottom of the page contains a label for each month of the current fiscal year showing total sales of the selected product per month.
When the page is first loaded, 3 ID's are passed from the previous page through a querystring to give me the id's required to load each of the 3 sections. Based on the 3rd one, a default product is selected in the dropdownlist and the labels are loaded accordingly.
Here's the problem:
Whenever I click in the dropdownlist to select a different product the page reloads and the customer data is gone, the dropdownlist is empty, and the labels show the previous information.
My OnSelectedIndexChanged event doesn't seem to connect with the dropdownlist. I have assigned hardcoded text to a label in the handler and it never gets set.
How can I refresh my page showing the new data based on the value selected in the dropdownlist?
Here's the code I am working with:
Dim pgSalesmanID As Integer
Dim pgCustomerID As Integer
Dim pgProductID As Integer
Dim curPos as Integer = 0
SUB Page_Load(sender as Object, e as EventArgs)
If (Request.QueryString("sID") <> "") then
pgSalesmanID = Convert.ToInt32(Request.QueryString("sID"))
If (Request.QueryString("cID") <> "") then
pgCustomerID = Convert.ToInt32(Request.QueryString("cID"))
If (Request.QueryString("pID") <> "") then
pgProductID = Convert.ToInt32(Request.QueryString("pID"))
If (Request.QueryString("pos") <> "") then
curPos = Convert.ToInt32(Request.QueryString("pos"))
IF NOT Page.isPostBack then
SUB productList_OnChange (sender As Object, e As EventArgs)
pgProductID = productList.SelectedItem.Value
Dim cn as SQLConnection
Dim cmd as SQLCommand
Dim rdr as SQLDataReader
Dim sConnectString as String = "connectionString"
Dim sSql as String = "sp_mySp '8, 250, 11"
cn = New SQLConnection(sConnectString)
cmd = New SQLCommand(sSQL, cn)
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
productList.DataSource = rdr
Catch myException As Exception
Response.Write("An error has occurred trying to load
Product: " & myException.ToString())
If Not rdr Is Nothing Then
productList.Items.Insert(0, "Select Product")
If (pgProductID <> 0) then
productList.SelectedValue = pgProductID
productList.SelectedIndex = 0
Then my grid:
<ASP:DropDownList id="productList" width="250"
I hope my question isn't to confusing. Thanks for any help you can provide.