Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
Hi I have one List <pre lang="c#">GenericCollection<PolicyPolicyRelation> obj = new GenericCollection<PolicyPolicyRelation>();</pre>


In every PostBack I want to keep the datas in viewstate by appending.But I am not able to append its replacing.

and after appending I want to fetch the array of viewsate to assign to a gridview.Can u please tell how to do.
Posted
Comments
Sergey Alexandrovich Kryukov 8-Mar-13 16:29pm    
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

1 solution

write this code on you Page_Load event

C#
public List<datetime> DateArray { get; set; }
 protected void Page_Load(object sender, EventArgs e)
        {
            this.DateArray = new List<datetime>();
            if (ViewState["DateArray"] != null)
                this.DateArray = (List<datetime>)ViewState["DateArray"];
            this.DateArray.Add(DateTime.Now);
            ViewState["DateArray"] = this.DateArray;
            if (!IsPostBack)
            {

            }
        }
</datetime></datetime></datetime>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900