Back to Devexpress

ASPxGridView.FindEditFormTemplateControl(String) Method

aspnet-devexpress-dot-web-dot-aspxgridview-dot-findeditformtemplatecontrol-x28-system-dot-string-x29.md

latest6.4 KB
Original Source

ASPxGridView.FindEditFormTemplateControl(String) Method

Searches for the specified server control contained within the Edit Form‘s template.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public Control FindEditFormTemplateControl(
    string id
)
vb
Public Function FindEditFormTemplateControl(
    id As String
) As Control

Parameters

NameTypeDescription
idString

A String value that identifies the control within the Edit Form.

|

Returns

TypeDescription
Control

A Control object that represents the control contained within the Edit Form.

|

Remarks

For more information, see Templates.

Example

For a full example, see Grid - Edit Form Templates demo.

csharp
protected string GetMemoText() {
     ASPxPageControl pageControl = grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
     ASPxMemo memo = pageControl.FindControl("notesEditor") as ASPxMemo;
     return memo.Text;
}
vb
Protected Function GetMemoText() As String
     Dim pageControl As ASPxPageControl = TryCast(grid.FindEditFormTemplateControl("pageControl"), ASPxPageControl)
     Dim memo As ASPxMemo = TryCast(pageControl.FindControl("notesEditor"), ASPxMemo)
     Return memo.Text
End Function
aspx
<dx:ASPxGridView ID="grid" runat="server" DataSourceID="DemoDataSource1" KeyFieldName="EmployeeID" 
        AutoGenerateColumns="False" OnRowUpdating="grid_RowUpdating" OnRowInserting="grid_RowInserting">
     <Columns>
          ...
          <dx:GridViewDataMemoColumn FieldName="Notes" Visible="False">
          </dx:GridViewDataMemoColumn>
          ...
     </Columns>
     ...
     <Templates>
            <EditForm>
                <div style="padding: 4px 3px 4px">
                    <dx:ASPxPageControl runat="server" ID="pageControl" Width="100%">
                        <TabPages>
                            <dx:TabPage Text="Info" Visible="true">
                                <ContentCollection>
                                    <dx:ContentControl runat="server">
                                        <dx:ASPxGridViewTemplateReplacement ID="Editors" ReplacementType="EditFormEditors"
                                            runat="server">
                                        </dx:ASPxGridViewTemplateReplacement>
                                    </dx:ContentControl>
                                </ContentCollection>
                            </dx:TabPage>
                            <dx:TabPage Text="Notes" Visible="true">
                                <ContentCollection>
                                    <dx:ContentControl runat="server">
                                        <dx:ASPxMemo runat="server" ID="notesEditor" Text='<%# Eval("Notes")%>' Width="100%" Height="93px" />
                                    </dx:ContentControl>
                                </ContentCollection>
                            </dx:TabPage>
                        </TabPages>
                    </dx:ASPxPageControl>
                </div>
                <div style="text-align: right; padding: 2px">
                    <dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton"
                        runat="server">
                    </dx:ASPxGridViewTemplateReplacement>
                    <dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton"
                        runat="server">
                    </dx:ASPxGridViewTemplateReplacement>
                </div>
            </EditForm>
     </Templates>
</dx:ASPxGridView>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FindEditFormTemplateControl(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-grid-initialize-editor-conditionally/CS/WebApplication_Grid/CustomEditForm.aspx.cs#L33

csharp
ASPxEdit editor = (ASPxEdit)grid.FindEditFormTemplateControl(editorID);
e.NewValues["DataValue"] = editor.Value.ToString();

asp-net-web-forms-grid-initialize-editor-conditionally/VB/WebApplication_Grid/CustomEditForm.aspx.vb#L31

vb
Dim editor As ASPxEdit = CType(grid.FindEditFormTemplateControl(editorID), ASPxEdit)
e.NewValues("DataValue") = editor.Value.ToString()

See Also

Grid View

Example: How to create edit form templates dynamically

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace