---
vb.net:
Dim gridTable As DataTable = CType(dataGrid1.DataSource, DataTable)
gridTable.DefaultView.Sort = "CompanyName DESC"
---
c#:
DataTable gridTable = (DataTable) dataGrid1.DataSource;
gridTable.DefaultView.Sort = "CompanyName DESC"
---
if (this.DataSource is DataTable)
{
DataTable table = (DataTable) this.DataSource;
if (sortExpression != null && sortExpression.Length > 0)
{
table.DefaultView.Sort = sortExpression + " " + sortOrder;
}
}
---
DataView sınıfını kullanarak da sıralama, arama ve filitreleme yapabiliriz.
vb.net
Dim dvEmpolyees as New DataView(dtEmployees)
dvEmployees.Sort = "DateOfHire"
dvEmployees.Sort = "DateOfHire, Department"
dvEmployees.Sort = "DateOfHire, Department DESC"
dvEmployees.Sort = "[Date Of Hire], Deparment"
c#
DataView dvEmployees = new DataView(dtEmployees);
dvEmployees.Sort = "DateOfHire";
dvEmployees.Sort = "DateOfHire, Department";
dvEmployees.Sort = "DateOfHire, Department DESC";
dvEmployees.Sort = "[Date Of Hire], Deparment";
kaynak:
http://weblogs.asp.net/jcogley/archive/2003/09/15/27567.aspx
http://www.knowdotnet.com/articles/dataviewsort.html
http://msdn.microsoft.com/en-us/library/system.data.datatable.defaultview(VS.71).aspx
Hiç yorum yok:
Yorum Gönder