Results 1 to 4 of 4

Thread: Customize dynamic data field template

  1. #1
    Join Date
    Apr 2009
    Posts
    29

    Customize dynamic data field template

    I use Dyanamic Data Field Template to make websites is just started using such things I had learned all about it, but has forgotten how to customize it... Is there anyone who know how to customize Dynamic Data Field Template...???

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Customize dynamic data field template

    Dynamic Data field templates are ASP.NET user controls that map data controls to data types in a data model. Field templates derive from FieldTemplateUserControl, the class that enables access to data fields, data columns, and metadata in data models. Dynamic Data projects provide some default field templates, but you can modify them or create custom field templates.

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Customize dynamic data field template

    The following code is a partial class Entity type created for the Dynamic Data feild :

    Code:
    partial void OnContextCreated()
            {
                this.SavingChanges += new
                    System.EventHandler(OnSavingChanges);
            }
     
    
            public void OnSavingChanges(object sender, System.EventArgs e)
            {
                var stateManager = ((TransitScheduleEntities)sender).ObjectStateManager;
                var changedEntities = stateManager.GetObjectStateEntries(EntityState.Modified);
     
                foreach (ObjectStateEntry stateEntryEntity in changedEntities)
                {
                    int modBy = stateEntryEntity.CurrentValues.GetOrdinal("ModifiedBy");
                    int modDate = stateEntryEntity.CurrentValues.GetOrdinal("DateModified");
                    if (modBy > 0)
                    {
                        stateEntryEntity.CurrentValues.SetValue(modBy, HttpContext.Current.User.Identity.Name);
                    }
                    if (modDate > 0)
                    {
                        stateEntryEntity.CurrentValues.SetValue(modDate, DateTime.Now);
                    }
                }
            }

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Customize dynamic data field template

    The following procedure shows how to add a background color to Text_Edit.ascx, one of the field templates provided in a Dynamic Data project by default. To customize a default field template :

    1. In Visual Studio 2008 or Visual Web Developer 2008 Express Edition open the ASP.NET Dynamic Data Web site.

    2. In the DynamicData/FieldTemplate folder, open the default field template you want to modifyand switch to Source view.

    3. Modify the code to customize the field template


    For example, you can add the following code snippet to modify the Text_Edit.ascx field template

    Code:
          <asp:TextBox ID="TextBox1" runat="server" BackColor="Yellow" Text='<%# FieldValueEditString %>'></asp:TextBox>
    This code snippet adds a background color property to the markup and sets it to yellow.

Similar Threads

  1. Replies: 6
    Last Post: 19-05-2011, 10:21 AM
  2. Ms Project 2007 Export And Data Field Format
    By edwormald in forum Windows Software
    Replies: 1
    Last Post: 01-05-2010, 05:36 PM
  3. Data Dictionary and Dynamic Performance Views
    By Lachlann in forum Software Development
    Replies: 4
    Last Post: 05-02-2010, 10:01 PM
  4. Display dynamic data in a table using Ajax
    By Hamlet in forum Software Development
    Replies: 4
    Last Post: 05-12-2009, 08:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,622,026.99395 seconds with 16 queries