locked
Dynamic multiple selection ListBox control? RRS feed

  • Question

  • User-696168318 posted

    Hi, all,


    I'm trying to implement the use case where a user moves selections from a long multiple-selection select element containing all possible values to a shorter multiple-selection select element containing their selections.  The shorter list is pre-loaded with their previous selections, pulled up from a database.


    I have two asp:ListBox tags, two asp:Buttons, and the JavaScript to move the elements working fine.  I was getting an error about an "Invalid postback or callback argument", so I read http://forums.asp.net/t/922994.aspx?PageIndex=2 and used RegisterForEventValidation to add all of the possible values to the shorter asp:ListBox to avoid this error.


    However, in my page's PreLoad event, I'm getting that the shorter asp:ListBox with the user's selections has an empty Items property, so I can't retrieve their selections.  Any advice?


    Regards,


        Don

    Wednesday, January 13, 2010 10:41 AM

Answers

  • User-1360095595 posted

    Manipulations you make client-side will not be visible server side.  So you might make use of a hiddenfield, where you can store all the IDs of the items (seperated by comma, or semi-colon, or whatever) that are moved to the user's selection list.  Now you can read this hiddenfield on the server, and know the items (maybe making use of String.Split()).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 13, 2010 10:59 AM

All replies

  • User-1360095595 posted

    Manipulations you make client-side will not be visible server side.  So you might make use of a hiddenfield, where you can store all the IDs of the items (seperated by comma, or semi-colon, or whatever) that are moved to the user's selection list.  Now you can read this hiddenfield on the server, and know the items (maybe making use of String.Split()).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 13, 2010 10:59 AM
  • User-696168318 posted

    Manipulations you make client-side will not be visible server side.  So you might make use of a hiddenfield, where you can store all the IDs of the items (seperated by comma, or semi-colon, or whatever) that are moved to the user's selection list.  Now you can read this hiddenfield on the server, and know the items (maybe making use of String.Split()).


    Okay, thanks.  I wasn't sure if I was doing something wrong or if what I was trying to do was not possible.

    Cheers!

    Wednesday, January 13, 2010 11:24 AM
  • User-1324173748 posted

    Manipulations you make client-side will not be visible server side

    I think it is possible using the following code on server i do it and Get 100% result.. find element by Value / Name / index its up to u

    lbBranch.Items.FindByValue(dr[0].ToString()).Selected = true; //using Value
    
    lbBranch.Items.FindByText(dr[0].ToString()).Selected = true; //using Text
    
    lbBranch.Items[2].Selected = true; //using Index
    Wednesday, June 29, 2011 5:58 AM