locked
Can Profile Parameter be used to affect AutoFilters in Dynamic Data? RRS feed

  • Question

  • User-635256440 posted
    You cannot vote on your own postI'm using a Profile parameter set at login as a value for filtering Gridview data of Entity Framework Dynamic Data application.  The QueryExtender seems works fine on the Gridview portion but leaves the dropdown menus automatically generated by DD unfiltered.  After reading many articles, I've almost concluded that this is not possible.  Can anyone please tell me if DD is capable of filtering the dropdown filters using Profile variable?  If so, how?  Thanks.

     Below is partial aspx code.

    <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>
    
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                    <asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
                        <ItemTemplate>
                            <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' OnPreRender="Label_PreRender" />
                            <asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" /><br />
                        </ItemTemplate>
                    </asp:QueryableFilterRepeater>
    
                <div class="DD">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                        HeaderText="List of validation errors" CssClass="DDValidator" />
                    <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" CssClass="DDValidator" />
                    <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:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="true" />
              
    <%-- Important to filter on Company from Profile setting--%>
               <asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
                    <asp:DynamicFilterExpression ControlID="FilterRepeater" />
                      <asp:SearchExpression DataFields="Company" SearchType="startswith">
                          <asp:ProfileParameter PropertyName="Company" />
                      </asp:SearchExpression>
               </asp:QueryExtender>
    
                <br />
    



    Monday, August 27, 2012 12:26 PM

Answers

  • User3866881 posted

    Hi,

    I think it should work:

    1)Please define your Profile like this following:

    File: Web.config
    
    <configuration>
    ……………………
    
      <system.web>
        <profile enabled="true">
          <properties>
            <add name="Company" defaultValue="Anonymous" />
          </properties>
        </profile>
      </system.web>
    
    </configuration>

    And then put a submit button,when click that,the whole page is submitted and it will filter the records according to the profile's configration……

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 28, 2012 9:54 PM

All replies

  • User3866881 posted

    Hi,

    I think it should work:

    1)Please define your Profile like this following:

    File: Web.config
    
    <configuration>
    ……………………
    
      <system.web>
        <profile enabled="true">
          <properties>
            <add name="Company" defaultValue="Anonymous" />
          </properties>
        </profile>
      </system.web>
    
    </configuration>

    And then put a submit button,when click that,the whole page is submitted and it will filter the records according to the profile's configration……

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 28, 2012 9:54 PM
  • User-635256440 posted

    Thanks Decker I'll try that. 

    Can the push-button be hidden and automated so that a user will not have to even depress it?  Perhaps employ the Page_Load section to accomplish this?  Any examples would be appreciated as I'm still learning.

    Wednesday, August 29, 2012 11:04 AM
  • User3866881 posted

    Can the push-button be hidden and automated so that a user will not have to even depress it?

    Why do you want the push-button be hidden?If you hide the button, there's no submit action to the webpage itself so that the records cannot be filtered out.

    Maybe you can make your Dropdownlist's AutoPostBack=true, or some controls' AutoPostBack=true.

    All in all,you should have to submit back to the page itself.

    Reguards!

    Wednesday, August 29, 2012 9:15 PM