Skip to content

Create a column edit item template, add a grid lookup control to the template, and use the control's DataSourceID property and Bind method to bind the control to data sources.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-web-forms-grid-use-two-way-data-bound-lookup-in-edit-form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET Web Forms - How to use a two-way data-bound grid lookup in the grid's edit form

This example demonstrates how to create a column edit item template, add a grid lookup control to the template, and use the control's DataSourceID property and Bind method to bind the control to data sources.

Two-way data-bound grid lookup

Overview

Create a combo box column and specify its EditItemTemplate property. Add a grid lookup control to the template and use its DataSourceID property to specify the control's data source. Then use the Bind method to bind the control's Value property to the corresponding field in the main grid's data source.

<dx:GridViewDataComboBoxColumn FieldName="CategoryID" VisibleIndex="1">
    <PropertiesComboBox DataSourceID="dsCategories" TextField="CategoryName" ValueField="CategoryID"
        ValueType="System.Int32">
    </PropertiesComboBox>
    <EditItemTemplate>
        <dx:ASPxGridLookup ID="glCategory" runat="server" AutoGenerateColumns="False" 
            DataSourceID="dsCategories" KeyFieldName="CategoryID" OnLoad="glCategory_Load" 
            TextFormatString="{1}" Value='<%# Bind("CategoryID") %>' Width="260px">
            <GridViewProperties>
                <SettingsBehavior AllowFocusedRow="True" AllowSelectByRowClick="True" 
                    AllowSelectSingleRowOnly="True" />
            </GridViewProperties>
            <Columns>
                <dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" 
                    Visible="False" VisibleIndex="0">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1" />
                <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2" />
            </Columns>
        </dx:ASPxGridLookup>
    </EditItemTemplate>
</dx:GridViewDataComboBoxColumn>

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Create a column edit item template, add a grid lookup control to the template, and use the control's DataSourceID property and Bind method to bind the control to data sources.

Topics

Resources

License

Stars

Watchers

Forks