|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
One comment about the implementation of SessionThat is, it is not a good idea to force both a key and its value to be of type String. It has no problem for most web controls. For example, for TextBox(es), we can have the following in the session bag: "txtFirstName": "John" "txtLastName": "Doe" But, the current session implementation is not handy when we have to store ListItem(s) of a multiple ListBox. For example, if I have on my web this multi-select ListBox (whose ID is lstbxFood): Select your favorite food: Hamberger Pizza Icecream French Fries Yogurt And suppose, a user selects the first 3 items: Hamberger, Pizza and Icecream. Then, we have a little problem storing in the session all 3 selected items for the key "lstbxFood". So, it would be nice if the value of a key in the session can be some kind of container which can hold multiple objects. What do you think? Session is not implemented this. The value is of type object. The key is
overloaded to either be a string or an index. It's very possible to do what you ask Session["Selections"] = new Array("Hamburger","Pizza","IceCream"); .... Array arr = Session["Selections"] as Array; foreach (string str in arr) { string.ToString() you get the idea } -- Show quoteHide quoteRegards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] The Microsoft Office Web Components Black Book with .NET Now Available @ www.lulu.com/owc Forth-coming VSTO.NET - Wrox/Wiley 2006 ------------------------------------------------------- <antonyliu2***@yahoo.com> wrote in message news:1132681020.142238.108920@f14g2000cwb.googlegroups.com... > I think it is a bad idea to implement session as a bag of string pairs. > That is, it is not a good idea to force both a key and its value to be > of type String. > > It has no problem for most web controls. For example, for TextBox(es), > we can have the following in the session bag: > > "txtFirstName": "John" > "txtLastName": "Doe" > > But, the current session implementation is not handy when we have to > store ListItem(s) of a multiple ListBox. > > For example, if I have on my web this multi-select ListBox (whose ID is > lstbxFood): > > Select your favorite food: > > Hamberger > Pizza > Icecream > French Fries > Yogurt > > And suppose, a user selects the first 3 items: Hamberger, Pizza and > Icecream. > > Then, we have a little problem storing in the session all 3 selected > items for the key "lstbxFood". > > So, it would be nice if the value of a key in the session can be some > kind of container which can hold multiple objects. > > What do you think? > Hey, that's what I want, then. Forget about my stupid comment. Thanks
a lot! This is actually already what your suggested (the value is an object, not a
string). -- Show quoteHide quotePatrice <antonyliu2***@yahoo.com> a écrit dans le message de news:1132681020.142238.108920@f14g2000cwb.googlegroups.com... > I think it is a bad idea to implement session as a bag of string pairs. > That is, it is not a good idea to force both a key and its value to be > of type String. > > It has no problem for most web controls. For example, for TextBox(es), > we can have the following in the session bag: > > "txtFirstName": "John" > "txtLastName": "Doe" > > But, the current session implementation is not handy when we have to > store ListItem(s) of a multiple ListBox. > > For example, if I have on my web this multi-select ListBox (whose ID is > lstbxFood): > > Select your favorite food: > > Hamberger > Pizza > Icecream > French Fries > Yogurt > > And suppose, a user selects the first 3 items: Hamberger, Pizza and > Icecream. > > Then, we have a little problem storing in the session all 3 selected > items for the key "lstbxFood". > > So, it would be nice if the value of a key in the session can be some > kind of container which can hold multiple objects. > > What do you think? >
Single Logon
How to Address Other Controls' IDs? Custom dropdownlist that displays a listbox Using DataList - table and headers DataItem in DataListItem is null. Microsoft Spreadsheet Control? .NET 2 Custom Control question GridView EnableSortingAndPagingCallbacks problem with the AutoPostBack property Strange temporary error after applying .Net SP1 |
|||||||||||||||||||||||