How to hold the list of Data in Viewstate of ?


While working on one of personal project there was requirement to hold the collection of data of some event and again i have to validate that data on some other event, then i did using Viewstate like this sample code

 protected void Button1_Click(object sender, EventArgs e)
        protected List<int> ViewStateList
                if (ViewState["Record"] == null) ViewState["Record"] = new List<int>();
                return (List<int>)ViewState["Record"];
        protected void Button2_Click(object sender, EventArgs e)
            foreach (int n in ViewStateList)

I hope this will help to somebody.


One thought on “How to hold the list of Data in Viewstate of ?

  1. blog search June 5, 2014 / 4:43 am

    This is my first time pay a visit at here and i am truly happy to read all at alone place.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.