禁用动态数据列表视图上的过滤
我有一组 NotificationTemplate 实体,其中每个实体都有一组零多个 SmsTemplate 实体。编辑或查看NotificationTemplate时,我有一个指向查看短信模板
的链接。该链接将我带到 SmsTemplates 实体集的列表视图,并针对我正在查看的 NotificationTemplate 进行筛选。
如何防止用户更改此过滤器以显示另一个 NotificationTemplate 的 SmsTemplates?也就是说,我想要过滤器,但它必须是只读的。下拉菜单不能下拉,它必须只显示这些 SmsTemplate 所属的 NotificationTemplate 的名称。要查看另一个NotificationTemplate 的SmsTemplates,用户必须从该其他模板中单击查看SMS 模板
。
I have an entity set of NotificationTemplates, and each one of these has a collection of zero-many SmsTemplate entities. When editing or viewing a NotificationTemplate, I have a link to View SMS Templates
. That link takes me to a List view for the SmsTemplates entity set, filtered for the NotificationTemplate I was viewing.
How can I prevent the user changing this filter to show SmsTemplates for another NotificationTemplate? That is, I want the filter, but it must be read only. The drop-down just mustn't drop down, it must just display the name of the NotificationTemplate that these SmsTemplates belong to. To view SmsTemplates for another NotificationTemplate, the user must click View SMS Templates
from that other template.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
过滤器模板的代码隐藏告诉过滤器从查询字符串中获取其值。它检查 DefaultValue 属性,并且如果设置为一个值,则将其分配给过滤器。您想要做的是添加逻辑,使过滤器在 DefaultValue 有值时变为只读。使其只读的最简单方法是禁用该控件。以下是默认 ForeignKey.ascx.cs 实现的操作方法:
The code-behind of the filter template is what tells the filter to pick up its value from the query string. It checks the DefaultValue property, and if set to a value, assigns that to the filter. What you want to do is add logic that makes the filter read-only when DefaultValue has a value . The simplest way to make it read-only this is to make the control disabled. Here's how you would do it for the default ForeignKey.ascx.cs implementation: