How to convert NameValue Collection when using ViewState

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicole - ASP/C# Beginner

    #1

    How to convert NameValue Collection when using ViewState

    Hi,

    I am trying to store a NameValue collection within a ViewState like this:
    StoreFilterSele ction = ViewState["StoreFilterSel ection"];

    YEt I recieve an error "Cannot implicityly convert type 'system.type' to
    'system.collect ions.specialize d.nameValueColl ection".

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

  • Shiva

    #2
    Re: How to convert NameValue Collection when using ViewState

    Hi,
    Assign the collection directly to the view state as in
    ViewState["StoreFilterSel ection"] = StoreFilterSele ction;

    While retrieving it, typecast explicitly:
    StoreFilterSele ction =
    (NameValueColle ction)(ViewStat e["StoreFilterSel ection"]);

    HTH.

    "Nicole - ASP/C# Beginner" <NicoleASPCBegi nner@discussion s.microsoft.com >
    wrote in message news:615BC8E8-9837-4290-938A-699CC938B6A6@mi crosoft.com...
    Hi,

    I am trying to store a NameValue collection within a ViewState like this:
    StoreFilterSele ction = ViewState["StoreFilterSel ection"];

    YEt I recieve an error "Cannot implicityly convert type 'system.type' to
    'system.collect ions.specialize d.nameValueColl ection".

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


    Comment

    • Nicole - ASP/C# Beginner

      #3
      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["StoreFilterSel ection"] = StoreFilterSele ction;
      >
      > While retrieving it, typecast explicitly:
      > StoreFilterSele ction =
      > (NameValueColle ction)(ViewStat e["StoreFilterSel ection"]);
      >
      > HTH.
      >
      > "Nicole - ASP/C# Beginner" <NicoleASPCBegi nner@discussion s.microsoft.com >
      > wrote in message news:615BC8E8-9837-4290-938A-699CC938B6A6@mi crosoft.com...
      > Hi,
      >
      > I am trying to store a NameValue collection within a ViewState like this:
      > StoreFilterSele ction = ViewState["StoreFilterSel ection"];
      >
      > YEt I recieve an error "Cannot implicityly convert type 'system.type' to
      > 'system.collect ions.specialize d.nameValueColl ection".
      >
      > Can I store a NameValuecollec tion in a viewstate and how can I read what is
      > save in this collection so I can update it from page to page.
      >
      >
      >[/color]

      Comment

      Working...