本文整理汇总了C#中System.Web.UI.WebControls.GridView.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# GridView.Sort方法的具体用法?C# GridView.Sort怎么用?C# GridView.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.GridView
的用法示例。
在下文中一共展示了GridView.Sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSortExpression
/// <summary>
/// Sorts the <see cref="GridView"/> control based on the specified sort expression and direction.
/// </summary>
/// <param name="gridView">A <see cref="GridView"/> object.</param>
/// <param name="sortParameterName">The <see cref="HttpRequest"/> parameter name for the sort expression.</param>
/// <param name="dirParameterName">The <see cref="HttpRequest"/> parameter name for the sort direction.</param>
public static void SetSortExpression(GridView gridView, String sortParameterName, String dirParameterName)
{
if ( !gridView.Page.IsPostBack && !gridView.Page.IsCallback && !String.IsNullOrEmpty(sortParameterName) )
{
String sort = HttpContext.Current.Request[sortParameterName];
if ( !String.IsNullOrEmpty(sort) )
{
SortDirection dir = SortDirection.Ascending;
if ( !String.IsNullOrEmpty(dirParameterName) )
{
String sortDir = HttpContext.Current.Request[dirParameterName];
if ( !String.IsNullOrEmpty(sortDir) )
{
dir = (SortDirection) Enum.Parse(typeof(SortDirection), sortDir);
}
}
gridView.Sort(sort, dir);
}
}
}
示例2: RestoreState
/// <summary>
/// Restores the state of the grid view and grid view search panel.
/// </summary>
/// <param name="gridView">The grid view.</param>
/// <param name="searchPanel">The search panel.</param>
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;
searchPanel.Filter = this.Filter;
if (!string.IsNullOrEmpty(this.SortExpression))
{
gridView.Sort(this.SortExpression, this.SortDirection);
}
}