Connecting Tech Pros Worldwide Forums | Help | Site Map

How to convert NameValue Collection when using ViewState

Nicole - ASP/C# Beginner
Guest
 
Posts: n/a
#1: Jul 21 '05
Hi,

I am trying to store a NameValue collection within a ViewState like this:
StoreFilterSelection = ViewState["StoreFilterSelection"];

YEt I recieve an error "Cannot implicityly convert type 'system.type' to
'system.collections.specialized.nameValueCollectio n".

Can I store a NameValuecollection in a viewstate and how can I read what is
save in this collection so I can update it from page to page.


Shiva
Guest
 
Posts: n/a
#2: Jul 21 '05

re: How to convert NameValue Collection when using ViewState


Hi,
Assign the collection directly to the view state as in
ViewState["StoreFilterSelection"] = StoreFilterSelection;

While retrieving it, typecast explicitly:
StoreFilterSelection =
(NameValueCollection)(ViewState["StoreFilterSelection"]);

HTH.

"Nicole - ASP/C# Beginner" <NicoleASPCBeginner@discussions.microsoft.com>
wrote in message news:615BC8E8-9837-4290-938A-699CC938B6A6@microsoft.com...
Hi,

I am trying to store a NameValue collection within a ViewState like this:
StoreFilterSelection = ViewState["StoreFilterSelection"];

YEt I recieve an error "Cannot implicityly convert type 'system.type' to
'system.collections.specialized.nameValueCollectio n".

Can I store a NameValuecollection in a viewstate and how can I read what is
save in this collection so I can update it from page to page.


Nicole - ASP/C# Beginner
Guest
 
Posts: n/a
#3: Jul 21 '05

re: How to convert NameValue Collection when using ViewState


thank you

"Shiva" wrote:
[color=blue]
> Hi,
> Assign the collection directly to the view state as in
> ViewState["StoreFilterSelection"] = StoreFilterSelection;
>
> While retrieving it, typecast explicitly:
> StoreFilterSelection =
> (NameValueCollection)(ViewState["StoreFilterSelection"]);
>
> HTH.
>
> "Nicole - ASP/C# Beginner" <NicoleASPCBeginner@discussions.microsoft.com>
> wrote in message news:615BC8E8-9837-4290-938A-699CC938B6A6@microsoft.com...
> Hi,
>
> I am trying to store a NameValue collection within a ViewState like this:
> StoreFilterSelection = ViewState["StoreFilterSelection"];
>
> YEt I recieve an error "Cannot implicityly convert type 'system.type' to
> 'system.collections.specialized.nameValueCollectio n".
>
> Can I store a NameValuecollection in a viewstate and how can I read what is
> save in this collection so I can update it from page to page.
>
>
>[/color]
Closed Thread