Results 1 to 3 of 3

Thread: dropdownlist selectedvalue problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    145

    dropdownlist selectedvalue problem

    Hi all,

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

    Code:
     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.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. 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.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    145
    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,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width