在Asp.Net动态数据应用使用DisplayColumnAttribute多个字段排序? [英] Sorting by multiple fields using DisplayColumnAttribute in Asp.Net Dynamic Data App?

查看:559
本文介绍了在Asp.Net动态数据应用使用DisplayColumnAttribute多个字段排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态数据的应用程序,我想基于像这样..

I've got a dynamic data app, and I want to sort based on multiple fields like so..

<DisplayColumn("FieldName", "Field1, Field2")> _

DisplayColumn似乎并不支持多个字段?

DisplayColumn doesn't seem to support more than one field?

推荐答案

该DisplayColumn属性的SortColumn参数指定要使用时,它被用来作为外键(例如:在DropDownList中),这个实体排序的列,不当它在GridView进行排序(或DB进行排序)。

The DisplayColumn attribute's SortColumn param specifies the column that will be used to sort this entity when it is used as a foreign key (ex: in a DropDownList), not when it is being sorted in the GridView (or being sorted in the DB).

看所以这里还有:
<一href=\"http://stackoverflow.com/questions/731502/asp-net-dynamic-data-displaycolumn-attribute-causing-sorting-issue\">http://stackoverflow.com/questions/731502/asp-net-dynamic-data-displaycolumn-attribute-causing-sorting-issue

MSDN:<一href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx\" rel=\"nofollow\">http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx

如果这仍然是你在找什么(在DropDownLists只,而不是数据库排序),你可以通过创建,结合这两列实体的自定义属性上多列排序。

If this is still what you are looking for (sorting in DropDownLists only, not the DB) you can sort on multiple columns by creating a custom property in the entity that combines those two columns.

例如:

[DisplayColumn("FieldName", "SortColumn")]
public partial class Employee
{
    public string SortColumn
    {
        get { return Field1 + Field2; }
    }
}

这篇关于在Asp.Net动态数据应用使用DisplayColumnAttribute多个字段排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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