为动态数据网站添加自定义过滤器(VS2010、EF4)
尝试使用 EF4 将一些不同的过滤器(除了外键过滤器之外)添加到 VS2010 中的动态数据网站。我可以添加新的过滤器模板,但如何指定为模型中的每个属性显示哪个模板?
谢谢
Trying to add some different filters (in addition to the ForeignKey filter) to a Dynamic Data Website in VS2010 using EF4. I can add the new Filter templates, but how do I specify which template will get displayed for each property in my model?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是执行此操作的步骤:
1) 在 DynamicData\Filters 下为所需的过滤器创建一个新的 UserControl。我创建了一个 TextFilter.ascx:
和后面的代码:
然后在您的模型中,只需使用指向下一个过滤器的 FilterUIHint 属性注释您的属性,就可以开始了
:
使用系统集合;
使用 System.Collections.Generic;
使用 System.Collections.ObjectModel;
使用 System.Collections.Specialized;
使用 System.ComponentModel.DataAnnotations;
命名空间测试.模型
{
公共部分类资产
{
#region 原始属性
...
Here are the steps for how to do this:
1) Create a new UserControl for the filter you want under DynamicData\Filters. I created a TextFilter.ascx:
and the code behind:
Then in your model, just annotate your properties with the FilterUIHint attribute pointing to the next filter and you're good to go:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
namespace Test.Model
{
public partial class Asset
{
#region Primitive Properties
...