How Dynamic data Filtering works with autofills?

Oct 9, 2008 at 12:08 PM
How Dynamic data filtering works when you add new items, passing DynamicFilterControls from DynamicFilterForm
 or DynamicFilterRepeater ?

Please see background infomation from first.



Oct 13, 2008 at 12:53 PM
I'm not quite sure what you are asking?  How are you adding new items?  Could you post complete code examples?
Oct 13, 2008 at 4:59 PM

What I really wanted is pass search key & value using DynamicFilterRepeater when insert new items. see code below

in List.aspx  I've replaced FilterRepeater to DynamicFilterRepeater. And Added OnClick="Button1_Click" to insert new button.

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

<%@ Register Assembly="Catalyst.Web.DynamicData" Namespace="Catalyst.Web.DynamicData"
    TagPrefix="asp" %>

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

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

    <h2>testing suppliers page <%= table.DisplayName%></h2>

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="List of validation errors" />
            <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />
<%--            <asp:FilterRepeater ID="FilterRepeater" runat="server">
                    <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
                    <asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
                <FooterTemplate><br /><br /></FooterTemplate>
            <asp:DynamicFilterRepeater ID="DynamicFilterRepeater" 
                    DataSourceID = "GridDataSource" runat="server">
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' ></asp:Label>
                                ID="DynamicFilter" runat="server">
                        <asp:LinkButton ID="SearchButton" runat="server" CommandName="Search" Text="Search">
                        </asp:LinkButton> <br />
                        <asp:LinkButton ID="ClearButton" runat="server" CommandName="Clear"

            <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource"
                AllowPaging="True" AllowSorting="True" CssClass="gridview">
                            <asp:HyperLink ID="EditHyperLink" runat="server"
                                NavigateUrl='<%# table.GetActionPath(PageAction.Edit, GetDataItem()) %>'
                            Text="Edit" />&nbsp;<asp:LinkButton ID="DeleteLinkButton" runat="server" CommandName="Delete"
                                CausesValidation="false" Text="Delete"
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'
                            />&nbsp;<asp:HyperLink ID="DetailsHyperLink" runat="server"
                                NavigateUrl='<%# table.GetActionPath(PageAction.Details, GetDataItem()) %>'
                                Text="Details" />

                <PagerStyle CssClass="footer"/>       
                    <asp:GridViewPager runat="server" />
                    There are currently no items in this table.
            <asp:DynamicLinqDataSource ID="GridDataSource"
                runat="server" >
            <br />

            <div class="bottomhyperlink">
                       <asp:LinkButton ID="LinkButton1" runat="server" OnClick="Button1_Click">
                              <img id="Img1" runat="server"
                            alt="Insert new item" />Insert new item</asp:LinkButton>

And in List.aspx.cs

    protected void Button1_Click(object sender, EventArgs e) {       
        RouteValueDictionary rd = new RouteValueDictionary();
        foreach (Control c in FilterRepeater.Controls)    ------------- using DynamicFilterRepeater here?
            foreach (Control d in c.Controls) {
                if (d is FilterUserControlBase)   ----------------------- ??
                    FilterUserControlBase fub = (FilterUserControlBase)d;
                    string key = fub.DataField;
                    string value = fub.SelectedValue;
                   rd.Add(key, value);
       string url = table.GetActionPath(PageAction.Insert, rd);

And in Insert.aspx.cs, added following

    protected void DetailsView1_DataBound(object sender, EventArgs e)
        foreach (MetaColumn column in table.Columns)
            string value = Request.QueryString[column.Name];
            if (!string.IsNullOrEmpty(value))
                var ftuc = DetailsView1.FindFieldTemplate(column.Name) as FieldTemplateUserControl;
                if (ftuc.DataControl is DropDownList)
                    var ddl = ftuc.DataControl as DropDownList;
                    ListItem item = ddl.Items.FindByValue(value);
                    if (item != null)
                        item.Selected = true;
                else if (ftuc.DataControl is CheckBox)
                    var cb = ftuc.DataControl as CheckBox;
                    cb.Checked = string.Compare(value, "true", true) == 0;


Oct 13, 2008 at 7:49 PM
Ah, I see what you are trying to do.  You are trying to pre-populate the inert form controls based on the values in the search criteria on the lists page.  Interesting... I'll try to test this out when I get a minute today.
Oct 13, 2008 at 9:37 PM
Thanks Josh. 
That's right. I wanted pre-populate the insert form controls based on the values in the search criteria (e.g. FilterMode = FilterControlMode.Equals) on the lists page.