Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

GridView - How to use GridLookup with single selection mode in EditForm

$
0
0

This example illustrates how to use GridLookup with single selection mode (SelectionMode is Single) in GridView for CRUD operations. By default, GridView doesn't have a built-in column for this scenario. The main idea is to use the MVCxGridViewColumn.SetEditItemTemplateContent method to place GridLookup in EditForm. The same approach will work for a custom EditForm (GridViewSettings.SetEditFormTemplateContent) as well.

In order to use client-side unobtrusive JavaScript validation with GridLookup, it's necessary to pass a correct model instance to a partial view. This instance should be of the same type as an item of the collection bound to GridView.

Controller:

[C#]
publicActionResultGridLookupPartial(int?KeyParameter){varmodel=GetModelInstanceByKey(KeyParameter);returnPartialView(model);}

 

[VB.NET]
PublicFunction GridLookupPartial(ByVal KeyParameter?AsInteger) As ActionResultDim model = GetModelInstanceByKey(KeyParameter)Return PartialView(model)EndFunction


 PartialView:

[C#]
@Html.DevExpress().GridLookup(settings=>{settings.Name=PropertyName;}).BindList(...).Bind(Model.PropertyName).GetHtml()
[VB.NET]
@Html.DevExpress().GridLookup(Sub(settings) settings.Name = PropertyNameEndSub).BindList(...).Bind(Model.PropertyName).GetHtml()


See also: 
GridView - How to use GridLookup in EditForm in multiple selection mode

Web Forms:
How to use two-way data-bound ASPxGridLookup in edit form of ASPxGridView to edit data
How to use ASPxGridLookup in multiple selection mode as the ASPxGridView editor

Question Comments

Added By: James Mayer at: 10/25/2018 11:46:51 AM    WEB FORM LINKS GO TO MVC EXAMPLES :)

Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>