如何按字段的长度排序ASP.NET DataGrid? [英] How do I sort an ASP.NET DataGrid by the length of a field?

查看:165
本文介绍了如何按字段的长度排序ASP.NET DataGrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGrid,其中每列都有一个SortExpression。我希望排序表达式相当于ORDER BY LEN(myField)。



我尝试过

  SortExpression =LEN(myField)

这会抛出异常,因为它不是有效的语法。任何想法?

解决方案

如何通过查询返回len,但不显示该列,仅将其用作您的原始列的排序表达式?



我不认为您的想法是默认支持的。


I have a DataGrid where each column has a SortExpression. I would like the sort expression to be the equivalent of "ORDER BY LEN(myField)".

I have tried

SortExpression="LEN(myField)" 

but this throws an exception as it is not valid syntax. Any ideas?

解决方案

What about returning the len by the query already, but don't show that column, only use it as your original column's sortexpression?

I don't think that your idea is supported by default.

这篇关于如何按字段的长度排序ASP.NET DataGrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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