Javascript populated ASP.NET ListBox has no "SelectedValue" on postback

Have two ASP.NET listboxes on my page.  One is populated via an SQLDataSource.  The other is populated via a javascript array.  When the user selects an item in the first box I have an event handler populate the second listbox with dependent data.

See my attached javascript function for the function that populates the second listbox...

The population happens as designed.  I am able to select a value in the first listbox and have the second is populated appropriately.  But the problem is in the postback.   I select a value in the second listbox and click OK...the postback happens and I make it to my event handler in the codebehind.  I can capture values for any other control on the page but when I try to access the second listbox the "SelectedValue" is an empty string.  Does this have to do with the fact that the second lstbox is populated in the browser and not from the codebehind or page load?

function LoadRightsListbox () 
   var lbxRights = $get(contentPlaceHolder + "lbxRights");
    var lbxRightCategories = $get(contentPlaceHolder + "lbxRightCategories");  
    var selectedRightCategoryID = lbxRightCategories.options[lbxRightCategories.selectedIndex].value;
    //clear list box 
    //populate the list box 
    var lbxIndex = 0; 
    for(var listIndex in rightsList) //alternative indexes (lbxIndex, listIndex) because the data IDs are not sequential
        if (rightsList[listIndex].getCategoryID() == selectedRightCategoryID)
            lbxRights.length = rightsList.length + 1;
            lbxRights.options[lbxIndex].text = rightsList[listIndex].getName();
            lbxRights.options[lbxIndex].value = rightsList[listIndex].getID();

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
Does this have to do with the fact that the second lstbox is populated in the browser and not from the codebehind or page load?
I have done this using a hidden field that I add the items to in javascript and then I check the hidden field in the code-behind for values and add them to the drop down or list box.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BruceAuthor Commented:
Thanks xDJR1875!

I did just what you suggested and it works.  

Thanks for the quick response.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.