Home > Enterprise Portal > State management(ViewState) in Enterprise portal

State management(ViewState) in Enterprise portal

I wrote a example about ViewState in one of earlier  post.  But while implementing ViewState in user control for Dynamics Ax2009 we need to  follow below steps:

  1. In the Page_Load event we have to initialize the ViewState variables to make sure these variables are initalized.

             Following is sample code :

          if (ViewState[“RECID”] != null)

         SelectedRecId = (Int64)ViewState[“RECID”]; 




        dbQuestionAnswerView = dsQuestionAnswer.GetDataSourceView(gridQuestionLines.DataMember).DataSetView;

          SelectedRecId = (Int64)dbQuestionAnswerView.GetCurrent().GetFieldValue(“RecId”); ;


          2.   The ViewState.Add method should be used in Page_PreRender event to add the desired variables in ViewState   when           page is rendered.

     Following is sample code :

          ViewState.Add(“RECID”, SelectedRecId);

Categories: Enterprise Portal
  1. September 20, 2010 at 7:45 am

    Thanks Sumit. This will help.

    Will this work, even if we disable statestore?

  2. October 2, 2010 at 10:16 am

    Good article, thanks ! my friends…

  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: