开发者

Custom sorting object datasource bound gridview

I want to sort my GridView bound to an object DataSource fetching business objects. I have al开发者_JS百科ready implemented custom paging & now want to implement sorting. Just read this article but there is lot of concatenation going on there with the SQL Query.

Any other elegant solution?

https://web.archive.org/web/20211020202742/https://aspnet.4guysfromrolla.com/articles/032206-1.aspx#


How about sorting using .DefaultView? Following is upon grd_Sorting event.

DataView dv = dt.DefaultView;//Your datatable, dt.
dv.RowFilter = "";//Set row filter to none.
if ((strSortBy != null) && (strSortAscending != null))
    dv.Sort = strSortBy/*Column name*/ + " " + strSortAscending /*ASC, for instance.*/;

grd.DataSource = dv;
grd.DataBind();


Solved it at query level with a dynamic where clause.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜