if(columnBindingName== "modifyfrequency") { DataTable dt = this.dgvMyIndex.DataSource as DataTable; EnumerableRowCollection<DataRow> dayquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "日" select order; EnumerableRowCollection<DataRow> weekquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "周" select order; EnumerableRowCollection<DataRow> xunquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "旬" select order; EnumerableRowCollection<DataRow> halfMonthquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "半月" select order; EnumerableRowCollection<DataRow> monthquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "月" select order; EnumerableRowCollection<DataRow> quaterquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "季度" select order; EnumerableRowCollection<DataRow> halfYearquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "半年" select order; EnumerableRowCollection<DataRow> Yearquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "年" select order; EnumerableRowCollection<DataRow> budingqiquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "不定期" select order; EnumerableRowCollection<DataRow> daidingquery = from order in dt.AsEnumerable() where order.Field<string>("modifyfrequency") == "待定" select order; DataTable newDataTable = dt.Clone(); if (sortMode=="asc") { foreach (var row in dayquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in weekquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in xunquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in halfMonthquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in monthquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in quaterquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in halfYearquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in Yearquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in budingqiquery) { newDataTable.Rows.Add(row.ItemArray); } foreach (var row in daidingquery) { newDataTable.Rows.Add(row.ItemArray); } } }