May 15

The DynamicFilter control is a special kind of control: it will let you use  ListControl to filter the data presented to the user (yes, this means that you can use any derived type of ListControl). The control exposes two important properties:

  • ColumnName: lets you set the name of the column you”re using in the filter;
  • FilterStyle: enumeration (called FilterStyle) that lets you specify the type of ListControl that should be generated for representing this control on the page.

Before you start using this control, do keep in mind that it”ll only work when you set it to a column that is a foreign key (ie, it gets its value from another table). To illustrate the control”s usage, lets just build a simple page that filters the contacts by user:

<html xmlns=”” >
 <head runat=”server”>
   <title>Untitled Page</title>
   <form id=”form1″ runat=”server”>
    <asp:DynamicFilter runat=”server” id=”myFilter” ColumnName=”StudentID”
          FilterStyle=”DropDown” />
    <asp:DynamicList id=”AutoData1″ runat=”server” />

By default, this will generate a DropDownList control that will list all the Students” names. Even though i didn”t had the time to use my “good old friend” Reflector, I do believe that you”ll get the students”s names because Name is the first column next to the primary key of the table (which you can check by taking a peek at the code I”ve used to create the tables).

1 comment so far

  1. Sergi Carreras
    11:15 am - 6-11-2007

    Hello Luis, thanks for your help !!!!

    I”m trying filtering, and works well. But I want to sort ( alphabetic ) the DropDownList content, and I don”t know how to do it. It”s possible ?

    Thank you a lot, and “saludos from Barcelona”