How To Apply Filters to exsisting LinkToSql Dynamic Data Site

Aug 26, 2009 at 9:12 PM

 Hello,

I have web app that I'm trying to construct, and I would like to include these handy filters to my App.

I have followed the turturiols that you have created from start to finish about 4 times now and I can't get anything to work. 

Below is a copy of my List.aspx page, that I have been trying to get working..this is a page from my custom page folder. I have added in the warning I get when I try to build/run this (it is in the middle of the code...I changed the text black). 

Any Help would be much appreciated..I'm new dynamic data but I have some apps that work great without this filtering, but I would sure like to use it.

 

<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="DynamicDataProject.List" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>

<%@ Register assembly="Catalyst.Web.DynamicData" namespace="Catalyst.Web.DynamicData" tagprefix="asp" %>

<asp:Content ID="headContent" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
        <DataControls>
            <asp:DataControlReference ControlID="GridView1" />
        </DataControls>
    </asp:DynamicDataManager>

    <h2 class="DDSubHeader"><%= table.DisplayName%></h2>
<p>This is Working</p>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="DD">
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                    HeaderText="List of validation errors" />
                <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />
                <asp:DynamicFilterRepeater  DataSourceID="GridDataSource" ID="DynamicFilterRepeater1" runat="server">
                    <HeaderTemplate>
                        <div>
                            Search</div>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>'></asp:Label><asp:DynamicFilterControl
                                ID="DynamicFilter" runat="server">
                            </asp:DynamicFilterControl>
                        </div>
                    </ItemTemplate>
                    <FooterTemplate>
                        <div>
                            <asp:LinkButton ID="SearchButton" runat="server" CommandName="Search" Text="Search">
                            </asp:LinkButton><asp:LinkButton ID="ClearButton" runat="server" CommandName="Clear"
                                Text="Clear">
                            </asp:LinkButton></div>
                    </FooterTemplate>
                </asp:DynamicFilterRepeater>
                
                <br />
            </div>

            <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
                AllowPaging="True" AllowSorting="True" CssClass="DDGridView"
                RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:DynamicHyperLink runat="server" Action="Edit" Text="Edit"
                            />&nbsp;<asp:LinkButton runat="server" CommandName="Delete" Text="Delete"
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'
                            />&nbsp;<asp:DynamicHyperLink runat="server" Text="Details" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

                <PagerStyle CssClass="DDFooter"/>        
                <PagerTemplate>
                    <asp:GridViewPager runat="server" />
                </PagerTemplate>
                <EmptyDataTemplate>
                    There are currently no items in this table.
                </EmptyDataTemplate>
            </asp:GridView>

            <asp:DynamicLinqDataSource ID="GridDataSource" EnableDelete="true" runat="server">
            </asp:DynamicLinqDataSource>
Warning 3 C:\Documents and Settings\ladamsx\My Documents\Visual Studio 2008\Projects\LinqToSqlProject\DynamicData\CustomPages\Matrixes\List.aspx: ASP.NET runtime error: The base class includes the field 'GridDataSource', but its type (Microsoft.Web.Data.UI.WebControls.LinqDataSource) is not compatible with the type of control (Catalyst.Web.DynamicData.DynamicLinqDataSource). C:\Documents and Settings\ladamsx\My Documents\Visual Studio 2008\Projects\LinqToSqlProject\DynamicData\CustomPages\Matrixes\List.aspx 72 1 LinqToSqlProject
            
            <aspX:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
                <asp:DynamicFilterExpression ControlID="FilterRepeater" />
            </aspX:QueryExtender>

            <br />

            <div class="DDBottomHyperLink">
                <asp:DynamicHyperLink ID="InsertHyperLink" runat="server" Action="Insert"><img runat="server" src="~/DynamicData/Content/Images/plus.gif" alt="Insert new item" />Insert new item</asp:DynamicHyperLink>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

Aug 31, 2009 at 3:13 PM

Hi, I have been trying the exact same thing using a custom list page and getting the same error.  Any input would be very helpful.

Ethel

Sep 1, 2009 at 2:06 AM

Hmm..

Couple of things:

First, I see that you are suing the QueryExtender which is part of the Dynamic Data Preview.  I am not sure how this is going to work with my Dynamic Data Filters targeting the 3.5 SP1 Framework version. 

Second, based on that error, I believe you need to check you Matrixes\List.aspx.designer.cs file.  I believe it is going to say that GridDataSource is of of type LinqDataSource, not DynamicLinqDataSource which it needs to be.

Hope that helps.

Sep 1, 2009 at 3:36 PM

Thanks!!  I will switch to 3.5 SP1 and give it a try.