PDA

Click to See Complete Forum and Search --> : dropdownlist selectedvalue problem


Marivic
Jun 2nd, 2004, 12:30 AM
Hi all,

I have this code in my page_load event of my user control.


If Not IsPostBack() Then
LoadLocations(lstLocation)
lstLocation.Attributes.Add("onchange", "javascript: document.Form1.submit()")

Select Case strDisplayMode.ToUpper
Case "RESULTS"
poPurchaseOrders.Find(strRequestedBy, strRaisedBy, strApprovedBy, strMatterNumber, strPurchaseOrderNumber, strOffice, intPageNumber, intRecordsOnPage)
Case "MYLIST"
poPurchaseOrders.Find(Session("EmployeeName"), "", "", "", "", "", intPageNumber, intRecordsOnPage)
Case Else
poPurchaseOrders.Find("", "", "", "", "", "", intPageNumber, intRecordsOnPage)
End Select
Else
poPurchaseOrders.Find("", "", "", "", "", lstLocation.SelectedValue, intPageNumber, intRecordsOnPage)
End If

DataGrid1.DataSource = poPurchaseOrders.Results
DataGrid1.RecordCount = poPurchaseOrders.RecordCount
DataGrid1.RecordsOnPage = intRecordsOnPage
DataGrid1.CurrentPage = intPageNumber
DataGrid1.QueryString = GetQueryString()
End If


The problem is after every postback, the value of the selectedvalue of the dropdownlistbox is not the current value but the previous value. So to illustrate, suppose the value of the dropdownlistbox are '1','2','3','4'.

If the user selects '2', it gets the selected initially which is '1'.....
then the user selects '3', it gets '2',
user selects '4', it gets '3',
user selects '1', it gets '4'

I might be missing something here.

Kindly help.

Thanks in advance.

crptcblade
Jun 2nd, 2004, 06:21 AM
lstLocation.Attributes.Add("onchange", "java script: document.Form1.submit()")


Can I assume that you are using this line to make the page post back when the user selects an item?

If so, try removing that line, and setting the dropdown's AutoPostback property to True, and see if that helps.

Marivic
Jun 2nd, 2004, 06:20 PM
Hi,

I tried that, but it's still the same. May I also add that the datagrid is also a user control inside this user control.

Thanks again,