Removing FilterRepeater and justing using DynamicFilter

Last post 05-13-2008 8:13 PM by Dave.Barker. 4 replies.

Sort Posts:

  • Removing FilterRepeater and justing using DynamicFilter

    05-13-2008, 12:14 PM
    • Loading...
    • Dave.Barker
    • Joined on 05-13-2008, 12:04 PM
    • Posts 5

    Hello all,

     

    I'm try to create a customer page that will not use the FilterRepeater but instead using a DynamicFilter that I have designated.

     

    This is what my code looks like

                <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
                <asp:DynamicFilter runat="server" ID="DynamicFilter" DataField="course_Name" OnSelectedIndexChanged="OnFilterSelectedIndexChanged"/>

     

    This is the error that I get ...

     Yes I have checked the "course_Number" field in a foreign key to another table named "Courses" in which the "course_Number" is the primary key.

    The reason I'm trying to do this in the first place is because when you use the FilterRepeater it creates a drop down list on a field from the Courses table named "Course_Name" which is not unique and does not have a foreign key defined in the "scheduled_classes table.

     

    Thanks in advanced for any help and by the way I'm just learning this stuff so please be gentle.

     

    Dave 

    Server Error in '/' Application.

    The filter control 'DynamicFilter' is associated with an unsupported column 'course_Number'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The filter control 'DynamicFilter' is associated with an unsupported column 'course_Number'.

    Source Error:

    Line 32:     protected void Page_Init(object sender, EventArgs e) {
    Line 33: if (!Page.IsPostBack) {
    Line 34: PopulateListControl(DropDownList1);
    Line 35:
    Line 36: // Set the initial value if there is one

    Source File: c:\Users\Dave\documents\visual studio 2008\websites\TCDB-Dynamic\DynamicData\Content\FilterUserControl.ascx.cs    Line: 34

    Stack Trace:

    [InvalidOperationException: The filter control 'DynamicFilter' is associated with an unsupported column 'course_Number'.]
    System.Web.DynamicData.FilterUserControlBase.EnsureInit() +2139
    System.Web.DynamicData.FilterUserControlBase.get_FilterDelegate() +28
    System.Web.DynamicData.FilterUserControlBase.PopulateListControl(ListControl listControl) +29
    FilterUserControl.Page_Init(Object sender, EventArgs e) in c:\Users\Dave\documents\visual studio 2008\websites\TCDB-Dynamic\DynamicData\Content\FilterUserControl.ascx.cs:34
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +41
    System.Web.UI.Control.OnInit(EventArgs e) +98
    System.Web.UI.UserControl.OnInit(EventArgs e) +96
    System.Web.UI.Control.InitRecursive(Control namingContainer) +369
    System.Web.UI.Control.InitRecursive(Control namingContainer) +196
    System.Web.UI.Control.InitRecursive(Control namingContainer) +196
    System.Web.UI.Control.InitRecursive(Control namingContainer) +196
    System.Web.UI.Control.InitRecursive(Control namingContainer) +196
    System.Web.UI.Control.InitRecursive(Control namingContainer) +196
    System.Web.UI.Control.InitRecursive(Control namingContainer) +196
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2031


    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434

     

     

  • Re: Removing FilterRepeater and justing using DynamicFilter

    05-13-2008, 2:29 PM
    • Loading...
    • sjnaughton
    • Joined on 04-29-2008, 5:11 PM
    • Newton-le-Willows, UK
    • Posts 655

    Hi Dave I'm not sure what your doing in your "DynamicFilter" if you post the source code and a sample of your table 5 or 6 rows and I could have a look.

    But my instinct its the relationship is this like:

    table1->link_table<-table2

     

    Steve

    Seeking the elegant solution.
    [Oh! If olny I colud tpye!Confused]
    c# Bits blog
    Filed under:
  • Re: Removing FilterRepeater and just using DynamicFilter

    05-13-2008, 5:30 PM
    • Loading...
    • Dave.Barker
    • Joined on 05-13-2008, 12:04 PM
    • Posts 5

    Sure,

     

    I have two table involved here one name Courses and the other Scheduled_Classes

    Courses has 4 columns

    course_number(PK, varchar(50) not null)
    course_name (varchar(100), not null)
    course_length (tinyint, null)
    course_category (FK, nvarchar(50), null

    Scheduled_Classes has 5 columns

    sched_num (PK,smallint,not null)
    class_date (smalldatetime,not null)
    room_num (FK,smallint,not null)
    eng_id (FK, smallint, null)
    course_number (FK, varchar(50), not null)

    Using the default ListDetails.aspx everything works great. I get 3 drop down filter lists.

    One for Instructor coming from the eng_id FK.
    One for Room coming from the room_num FK
    One from Course coming from the course_number FK

    The problem is column that it is picking to use for the filter is the course_name from courses table and I want it to filter on the course_number

    So I was trying to create a custom page that would do this.

     

    Here is the source code for my custom ListDetails.aspx

                "Label1" runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
                "server" ID="DynamicFilter" DataField="course_Number" OnSelectedIndexChanged="OnFilterSelectedIndexChanged"/>
     
    Thanks for your help
     
    Dave   

  • Re: Removing FilterRepeater and just using DynamicFilter

    05-13-2008, 6:03 PM
    Answer
    • Loading...
    • sjnaughton
    • Joined on 04-29-2008, 5:11 PM
    • Newton-le-Willows, UK
    • Posts 655

    I think you may not need to do this DynamicFilter I think you can do what you want to via attributes if you look at Dynamic Data Attributes on Maíra Wenzel's Blog you will find a list of most of the DynamicData Attributes the on I think you need is DisplayColumnAttribute which "Specifies which column to display (in filters or in foreign key links). By default, Dynamic Data uses the first column of type string that it finds."

    Hope this helps

    Steve

    Seeking the elegant solution.
    [Oh! If olny I colud tpye!Confused]
    c# Bits blog
  • Re: Removing FilterRepeater and just using DynamicFilter

    05-13-2008, 8:13 PM
    • Loading...
    • Dave.Barker
    • Joined on 05-13-2008, 12:04 PM
    • Posts 5

     Sounds like you are right I will read the post and report back.


    Thanks 

     

     

    Wow that is easy!

    That link also showed me how to get my date and money columns formatted correctly .

     

    Thanks again

    Dave 

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter