如何获取数据表的排序表达式 [英] How to get Sort Expression of datatable

查看:85
本文介绍了如何获取数据表的排序表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个数据表如何获取数据表的SortExpression


Hi All,

I have a datatable How can I can I get SortExpression of Datatable
Exmple Like

DataTable data = objAllDetail.Search();



如何获取数据的SortExpression,请帮忙

谢谢



How can I get SortExpression of data please help

Thanks

推荐答案

使用以下表达式

Use following expression

Datatable.DefaultView.Sort = "ColumnToSortOn ASC"; 



希望有帮助.
-Milind



Hope that helps.
-Milind


尝试类似的方法,
Try something like this,
void Sort_Grid(Object sender, DataGridSortCommandEventArgs e)
      {
         // Retrieve the data source from session state.
         DataTable dt = (DataTable)Session["Source"];

         // Create a DataView from the DataTable.
         DataView dv = new DataView(dt);

         // The DataView provides an easy way to sort. Simply set the 
         // Sort property with the name of the field to sort by.
         dv.Sort = e.SortExpression;

         // Re-bind the data source and specify that it should be sorted
         // by the field specified in the SortExpression property.
         ItemsGrid.DataSource = dv;
         ItemsGrid.DataBind();
      }



[



Source [^]


这篇关于如何获取数据表的排序表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆