ViewState and ListBox

Hi Experts,

I am having a ListBox,thae data of which I want to store in the ViewState (multicolumn Listbox).I want to know that if user has changed the values in the listbox on Save event.

  private void FillSelectedRole(int siteId,int levelId)
            //ViewState["SelectedItemCount_"] = 0;
            SkillUpdateRight skUpdateRights = new SkillUpdateRight();
            Dictionary<object, object> dictRoleSelected = skUpdateRights.GetSelectedRole(siteId,levelId);
            foreach (KeyValuePair<object, object> kvp in dictRoleSelected)
                ListItem li = new ListItem(kvp.Value.ToString(), kvp.Key.ToString());
                li.Selected = true;

              //How to store items in viewstate

protected void imgbtnSave_Command(object sender, CommandEventArgs e)
            //How to check previous items in viewstate and newly selected items
Johny BravoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.


Implement the appropriate ListBox Changed event. It's as simple as checking for a change in that event, and setting a property to true. Then when they hit the save command, you can check if that property is true, deal with the changes, and then set it back to false for next time.


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
Johny BravoAuthor Commented:
I think I haven't explained well.
I have a listbox populated from db.
I want to hold these items in the viewstate.
There is another listbox,with which user can add or remove the items for first Listbox.
I need to check if the user has changed the previous List.
You can still use the listbox change event to detect that.

Johny BravoAuthor Commented:
Hi alainbryden
I am using a JQuery plugin for listbox
Here is the link.

So the listbox is a single control having two parts, available list and selected list.
there is no event fired as it is a jqery plugin.

any other idea?
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
.NET Programming

From novice to tech pro — start learning today.