London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Store multiple values in an attribute?

Vote:
 

Is it possible to store multiple values in an attribute?

In my case I have a ListBox with SelectionMode=Multiple, where I want to be able to save and retrieve all selections easily. Is it possible to do something like below?

public List<int> Ids
{
    get { return GetAttributeValue<List<int>>("Ids"); }

    set { SetAttributeValue<List<int>>("Ids", value); }
}

Thank you in advance!

#21040
Jun 19, 2008 11:31
Vote:
 

Never mind, I missed out that a GetAttributeValues method existed Laughing

Solution below seems to work fine.

public IList<int> Ids
{
get { return (IList<int>)GetAttributeValues<int>("Ids"); }
set { SetAttributeValue<int>("Ids", value); }
}
#21048
Edited, Jun 19, 2008 13:50
Vote:
 

Hi,

Yes this is possible by calling SetAttributeValues like this:

List<int> list = new List<int>();
list.Add(1);
list.Add(2);
SetAttributeValues("IDs", list);

You can also do the same with complex values:

List<Blog> list = new List<Blog>();
list.Add(BlogHandler.GetBlog(1));
list.Add(BlogHandler.GetBlog(2));
SetAttributeValues("Blogs", list);

 

#21049
Edited, Jun 19, 2008 13:50
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.