Template Replacements

  • 5 minutes to read

When you create a template, you often need to only extend the base control functionality. To help you easily customize the edit form and pager bar while keeping regular controls (edit cells, Update and Cancel buttons, pager), the ASPxGridViewTemplateReplacement control is designed. It allows you to put template replacements into your template; these replacements fully keep the base control functionality. Template replacements are displayed as regular controls within a grid using style settings, defining on the control level (via the ASPxGridView.Styles, ASPxGridView.StylesEditors, and ASPxGridView.StylesPager properties). The ASPxGridViewTemplateReplacement.ReplacementType property specifies the controls that are displayed by the ASPxGridViewTemplateReplacement control.

For an example on how to use the template replacements, see Grid Editing - Edit Form Template online demo.

 

The table below contains a list of the ReplacementType property values, the template types it can be used in and controls it contains.

ReplacementType property value Template type Contained controls
EditFormContent GridViewTemplates.EditForm Edit form's entire contents (edit cells and buttons)
EditFormEditors GridViewTemplates.EditForm Edit cell of each field within a grid
EditFormCellEditor GridViewTemplates.EditForm Edit cell
EditFormUpdateButton GridViewTemplates.EditForm Update button
EditFormCancelButton GridViewTemplates.EditForm Cancel button
Pager GridViewTemplates.PagerBar Pager

Edit form template replacements

Edit form template replacements allow you to add regular controls to an edit form template. Note that the regular form editors created by the ASPxGridViewTemplateReplacement control are automatically validated on the client if their validation settings are defined on a column level.

 

Pager template replacement

Set the ASPxGridViewTemplateReplacement.ReplacementType property to GridViewTemplateReplacementType.Pager to get a pager within your template. Note you can use this type of template replacement within the GridViewTemplates.PagerBar template only.

 

<PagerBar>
     <table>
          <tr>
               <td>
                    <dx:ASPxGridViewTemplateReplacement ID="ASPxGridViewTemplatePager" ReplacementType="Pager" runat="server">
                    </dx:ASPxGridViewTemplateReplacement>                             
               </td>

          ...

          </tr>
     </table>
</PagerBar>

ASPxGrigView_PagerTemplateReplacement

To see a sample of usage of this template replacement type, refer to the following Code Central example: How to embed export buttons in the ASPxGridView pager.

See Also