Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are the steps for how to do this:</p> <p>1) Create a new UserControl for the filter you want under DynamicData\Filters. I created a TextFilter.ascx:</p> <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TextFilter.ascx.cs" Inherits="Test.Prototype.Web.DynamicData.DynamicData.Filters.TextFilter" %&gt; &lt;asp:TextBox runat="server" ID="TextBox1" AutoPostBack="true" OnTextChanged="TextBox1_OnTextChanged" CssClass="DDFilter"&gt; &lt;/asp:TextBox&gt; </code></pre> <p>and the code behind:</p> <pre><code>using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Linq.Expressions; using System.Web.DynamicData; using System.Web.UI; using System.Web.UI.WebControls; namespace Test.Prototype.Web.DynamicData.DynamicData.Filters { public partial class TextFilter : System.Web.DynamicData.QueryableFilterUserControl { private const string NullValueString = "[null]"; protected void Page_Load(object sender, EventArgs e) { } public override Control FilterControl { get { return TextBox1; } } protected void TextBox1_OnTextChanged(object sender, EventArgs e) { OnFilterChanged(); } public override IQueryable GetQueryable(IQueryable source) { string selectedValue = TextBox1.Text; if (String.IsNullOrEmpty(selectedValue)) { return source; } object value = selectedValue; if (selectedValue == NullValueString) { value = null; } if (DefaultValues != null) { DefaultValues[Column.Name] = value; } return ApplyEqualityFilter(source, Column.Name, value); } } } </code></pre> <p>Then in your model, just annotate your properties with the FilterUIHint attribute pointing to the next filter and you're good to go:</p> <p>using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized;</p> <p>using System.ComponentModel.DataAnnotations;</p> <p>namespace Test.Model { public partial class Asset { #region Primitive Properties</p> <pre><code> public virtual int Id { get; set; } [FilterUIHint("TextFilter")] public virtual string Name { get; set; } </code></pre> <p>...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COMuch appreciated!
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload