locked
Custom pages and filtering. RRS feed

  • Question

  • User-2146101396 posted

    Hi guys, just started using the dynamic data site for a work project and i run in some required functionality that i need help with.

    1)  First of all is there any way of creating a custom page for each table instead of the ready templates? I am using the following code to use the list details page.

     

    routes.Add(New DynamicDataRoute("{table}/ListDetails.aspx") With { _

    .Action = PageAction.List, _

    .ViewName =
    "ListDetails", _

    .Model = model})

    routes.Add(
    New DynamicDataRoute("{table}/ListDetails.aspx") With { _

    .Action = PageAction.Details, _

    .ViewName =
    "ListDetails", _

    .Model = model})

     

    2)

    I know that filters appear if there is a foreign key in the database. Can i implement a filter (dropdownlist, search from textobox etc) without the field being foreign?

    Thanxs in advance!

     

    Monday, September 15, 2008 6:16 AM

Answers

All replies

  • User-330204900 posted

    Hi PanosP, for

    1) Are you talking about custome pages? If so you could use the preview of the DD Wizard Download Dynamic Data Wizard which will allow you to create custom pages for each table in the model with any of the Details, Edit, List etc components on the page.

    2) I have a series of articles on my blog here:

    1. Part 1 - Getting Dynamic Data Futures filters working in a File Based Website.
    2. Part 2 - Create the AnyColumn filter from the Dynamic Data Futures Integer filter.
    3. Part 3 – Creating the AnyColumnAutocomplete filter.

    The first set's about getting DD Futures working on a File Base website (Not a Web Application Project) and the second two are about using the filter capability on any column.

    Hope this helps [:D]

    Monday, September 15, 2008 7:22 AM
  • User-2146101396 posted

    Hi sjnaughton ,

    The wizard looks very good but i did it manually anyway by just copying the listdetails.aspx to a folder (table name) i created in the custompages folder.

    The reason that i want custom pages for my tables is because of the different requirements of each table.

    So lets say for my table A i want to implement a search function using a field to narrow down the results. If i edit the griddatasource by inserting a where clause based on the textbox value the functionality works but is there any other more elegant solution?

    Moreover in the edit and insert  mode some fields i want them to be sourced using a dropdown list from other tables in my database so to avoid mistakes. How can i manage this functionality.

    My project is a web application using vb .net.

     

    Monday, September 15, 2008 8:11 AM
  • User-330204900 posted

    Hi PanosP,

    For your first question in the code behind you can add a where parameter to the GridDataSource or you could look at this ASP.NET Dynamic Data Filtering on codeplex it expands greatly on the default filtering.

    for your second question I have a series of posts on my blog here:

    1. Your First FieldTemplate.
    2. An Advanced FieldTemplate.
    3. A Second Advanced FieldTemplate.
    4. An Advanced FieldTemplate with a GridView.
    5. An Advanced FieldTemplate with a DetailsView.
    6. An Advanced FieldTemplate with a GridView/DetailsView Project

    you will probably find the An Advanced FieldTemplate and A Second Advanced FieldTemplate. will be mose use to you.

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 15, 2008 8:31 AM
  • User-2146101396 posted

    i am having problems validating some fields. In the listdetails.page when i do an insert without any values a record is inserted with null values.

    the approach i am using is by creating a classs in the app code folder with the name of the table and using the following code:

    Imports System.Web.DynamicData

    Imports System.ComponentModel.DataAnnotations

    <MetadataType(GetType(concessionmetadata))> Partial Public Class FactConcessionMap_100

    End ClassPublic Class concessionmetadata

    <Required()> _

    Public VendorNo As Object

    <Required()> _

    Public ItemCategory As Object

    <Required()> _

    Public StoreName As Object

    <Required()> _

    Public Commission As Object

    End Class

    Also my listdetails page:

    <%@ Page Language="VB" MasterPageFile="~/Site.master" CodeBehind="ListDetails.aspx.vb" Inherits="ermesdynamicdatawebsite.factconcessionListDetails" %>

    <%@ 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:Button ID="Button1" runat="server"

    style="top: 218px; left: 314px; position: absolute; width: 117px; height: 22px;"

    Text="Search Vendor No" />

    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    <h2><%= GridDataSource.GetTable().DisplayName %></h2>

    <asp:TextBox ID="TextBox1" runat="server"

     

    style="position: absolute; top: 218px; left: 436px; height: 22px; width: 128px; margin-top: 0px"></asp:TextBox>

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

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">

    <ContentTemplate>

    <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"

    HeaderText="List of validation errors" />

    <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />

    <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1" Display="None" />

     

    <asp:FilterRepeater ID="FilterRepeater" runat="server">

    <ItemTemplate>

    <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />

    <asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />

    </ItemTemplate>

    <FooterTemplate><br /><br /></FooterTemplate>

    </asp:FilterRepeater>

     

    <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource"

    AutoGenerateSelectButton="True" AutoGenerateEditButton="True"

    AllowPaging="True" AllowSorting="True" OnDataBound="OnGridViewDataBound"

    OnRowEditing="OnGridViewRowEditing" OnSelectedIndexChanging="OnGridViewSelectedIndexChanging"

    OnRowDeleted="OnGridViewRowDeleted" OnRowUpdated="OnGridViewRowUpdated"

    OnRowCreated="OnGridViewRowCreated" CssClass="gridview"

    AutoGenerateColumns="False" DataKeyNames="SK"

    AutoGenerateDeleteButton="True">

    <PagerStyle CssClass="footer" />

    <SelectedRowStyle CssClass="selected" />

    <Columns>

    <asp:BoundField DataField="SK" HeaderText="SK" InsertVisible="False"

    ReadOnly="True" SortExpression="SK" Visible="False" />

    <asp:TemplateField HeaderText="VendorNo" SortExpression="VendorNo">

    <EditItemTemplate>

    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("VendorNo") %>'></asp:TextBox>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label1" runat="server" Text='<%# Bind("VendorNo") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:TemplateField HeaderText="ItemCategory" SortExpression="ItemCategory">

    <EditItemTemplate>

    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ItemCategory") %>'></asp:TextBox>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label2" runat="server" Text='<%# Bind("ItemCategory") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:TemplateField HeaderText="StoreName" SortExpression="StoreName">

    <EditItemTemplate>

    <asp:DropDownList DataSourceID="SqlDataSource1" DataTextField="storename" DataValueField="storename" ID="DropDownList4" Runat="server" selectedvalue='<%# Bind("Storename") %>'>

    </asp:DropDownList>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label3" runat="server" Text='<%# Bind("StoreName") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:TemplateField HeaderText="Commission" SortExpression="Commission">

    <EditItemTemplate>

    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Commission") %>'></asp:TextBox>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Commission") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    </Columns>

    <PagerTemplate>

    <asp:GridViewPager runat="server" />

    </PagerTemplate>

    <EmptyDataTemplate>

    There are currently no items in this table.

    </EmptyDataTemplate>

    </asp:GridView>

    <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="True"

    EnableUpdate="True"

    ContextTypeName="ermesdynamicdatawebsite.DataClasses1DataContext"

    TableName="FactConcessionMap_100s" Where="VendorNo == @VendorNo">

    <WhereParameters>

    <asp:ControlParameter ControlID="TextBox1" Name="VendorNo" PropertyName="Text"

    Type="String" />

    </WhereParameters>

    </asp:LinqDataSource>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

    ConnectionString="<%$ ConnectionStrings:ermesSAConnectionString %>"

    SelectCommand="SELECT DISTINCT StoreName AS storename FROM FactConcessionMap_100 ORDER BY storename">

    </asp:SqlDataSource>

    <asp:Panel ID="DetailsPanel" runat="server">

    <br /><br />

    <asp:DetailsView ID="DetailsView1" runat="server"

    DataSourceID="DetailsDataSource" CssClass="detailstable" FieldHeaderStyle-CssClass="bold"

    AutoGenerateEditButton="true" AutoGenerateInsertButton="true"

    OnModeChanging="OnDetailsViewModeChanging" OnPreRender="OnDetailsViewPreRender"

    OnItemDeleted="OnDetailsViewItemDeleted"

    OnItemUpdated="OnDetailsViewItemUpdated"

    OnItemInserted="OnDetailsViewItemInserted">

    <FieldHeaderStyle CssClass="bold" />

    </asp:DetailsView>

     

    <asp:LinqDataSource ID="DetailsDataSource" runat="server"

    ContextTypeName="ermesdynamicdatawebsite.DataClasses1DataContext"

    TableName="FactConcessionMap_100s" EnableDelete="True" EnableInsert="True"

    EnableUpdate="True">

    <WhereParameters>

    <asp:Parameter />

    </WhereParameters>

    </asp:LinqDataSource>

    </asp:Panel>

    </ContentTemplate>

    </asp:UpdatePanel>

    </asp:Content>

     

    Tuesday, September 16, 2008 3:42 AM
  • User-2146101396 posted

    Got it working now the class was not compiling properly. Its built action was set to content instead of compile!!

     

    Tuesday, September 16, 2008 5:29 AM