Index: WebLibrary/UI/GridViewSearchPanelState.cs.cst
===================================================================
--- WebLibrary/UI/GridViewSearchPanelState.cs.cst (revision 0)
+++ WebLibrary/UI/GridViewSearchPanelState.cs.cst (revision 0)
@@ -0,0 +1,160 @@
+<%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="" Debug="True" ResponseEncoding="UTF-8" %>
+<%@ Property Name="RootNameSpace" Type="System.String" Category="Data" Description="Website Namespace." %>
+
+#region Using Directives
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Web.UI.WebControls;
+using <%=RootNameSpace%>;
+#endregion
+
+namespace <%=RootNameSpace%>.Web.UI
+{
+ ///
+ /// Used to store important GridView and GridViewSearchPanel properties
+ /// so that their state can be maintained
+ ///
+ public class GridViewSearchPanelState
+ {
+ #region Properties
+ #region GridView
+ private int m_PageIndex;
+ ///
+ /// Gets or sets the index of the page.
+ ///
+ /// The index of the page.
+ public int PageIndex
+ {
+ get { return m_PageIndex; }
+ set { m_PageIndex = value; }
+ }
+
+ private int m_PageSize;
+ ///
+ /// Gets or sets the size of the page.
+ ///
+ /// The size of the page.
+ public int PageSize
+ {
+ get { return m_PageSize; }
+ set { m_PageSize = value; }
+ }
+
+ private string m_SortExpression;
+ ///
+ /// Gets or sets the sort expression.
+ ///
+ /// The sort expression.
+ public string SortExpression
+ {
+ get { return m_SortExpression; }
+ set { m_SortExpression = value; }
+ }
+
+ private SortDirection m_SortDirection;
+ ///
+ /// Gets or sets the sort direction.
+ ///
+ /// The sort direction.
+ public SortDirection SortDirection
+ {
+ get { return m_SortDirection; }
+ set { m_SortDirection = value; }
+ }
+ #endregion
+
+ #region GridViewSearchPanel
+ private string m_SearchKeyword;
+ ///
+ /// Gets or sets the search keyword.
+ ///
+ /// The search keyword.
+ public string SearchKeyword
+ {
+ get { return m_SearchKeyword; }
+ set { m_SearchKeyword = value; }
+ }
+
+ private string m_SearchFieldName;
+ ///
+ /// Gets or sets the name of the search field.
+ ///
+ /// The name of the search field.
+ public string SearchFieldName
+ {
+ get { return m_SearchFieldName; }
+ set { m_SearchFieldName = value; }
+ }
+
+ private SearchOperator m_SearchOperator;
+ ///
+ /// Gets or sets the search operator.
+ ///
+ /// The search operator.
+ public SearchOperator SearchOperator
+ {
+ get { return m_SearchOperator; }
+ set { m_SearchOperator = value; }
+ }
+ #endregion
+
+ #endregion
+
+ #region Constructors
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public GridViewSearchPanelState()
+ {
+
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The grid view.
+ /// The search panel.
+ public GridViewSearchPanelState( GridView gridView, GridViewSearchPanel searchPanel )
+ {
+ SaveState( gridView, searchPanel );
+ }
+ #endregion
+
+ #region Public methods
+ ///
+ /// Saves the state of the grid view and grid view search panel.
+ ///
+ /// The grid view.
+ /// The search panel.
+ public void SaveState( GridView gridView, GridViewSearchPanel searchPanel )
+ {
+ // Grid view values
+ this.PageIndex = gridView.PageIndex;
+ this.PageSize = gridView.PageSize;
+ this.SortExpression = gridView.SortExpression;
+ this.SortDirection = gridView.SortDirection;
+
+ this.SearchFieldName = searchPanel.SearchFieldName;
+ this.SearchOperator = searchPanel.SearchOperator;
+ this.SearchKeyword = searchPanel.SearchKeyword;
+ }
+
+ ///
+ /// Restores the state of the grid view and grid view search panel.
+ ///
+ /// The grid view.
+ /// The search panel.
+ public void RestoreState( ref GridView gridView, ref GridViewSearchPanel searchPanel )
+ {
+ gridView.PageIndex = this.PageIndex;
+ gridView.PageSize = this.PageSize;
+
+ searchPanel.SearchFieldName = this.SearchFieldName;
+ searchPanel.SearchKeyword = this.SearchKeyword;
+ searchPanel.SearchOperator = this.SearchOperator;
+ }
+ #endregion
+
+ }
+}