aspnet-devexpress-dot-web-dot-mvc-dot-gridsettingsbase.md
Gets or sets the name of the data source key field.
Namespace : DevExpress.Web.Mvc
Assembly : DevExpress.Web.Mvc5.v20.1.dll
NuGet Package : DevExpress.Web.Mvc5
public string KeyFieldName { get; set; }
Public Property KeyFieldName As String
| Type | Description |
|---|---|
| String |
A String value that specifies the name of the data source key field.
|
The KeyFieldName property should be specified when using the following GridView extension features:
Note
The GridSettingsBase property supports a composite KeyFieldName property value. You can use semicolon-separated values to specify multi-field keys, for example:
@Html.DevExpress().GridView(
settings => {
settings.KeyFieldName = "id1;id2";
...
...
protected Action DeletePartial(int id1, int id2)
....
@Html.DevExpress().GridView(settings => {
settings.Name = "gvDataBindingToLinq";
settings.CallbackRouteValues = new { Controller = "DataBinding", Action = "DataBindingToLargeDatabasePartial" };
settings.KeyFieldName = "ID";
...
}).BindToEF(string.Empty, string.Empty, (s, e) => {
e.QueryableSource = LargeDatabaseDataProvider.DB.Emails;
}).GetHtml()
The following code snippets (auto-collected from DevExpress Examples) contain references to the KeyFieldName property.
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-mvc-grid-export-multiple-gridviews-into-a-document/CS/Controllers/HomeController.cs#L28
categoriesGridSettings.Name = "gvCategories";
categoriesGridSettings.KeyFieldName = "CategoryID";
categoriesGridSettings.Columns.Add("CategoryID");
mvc-gridview-export-data-to-different-formats/CS/Controllers/HomeController.cs#L59
settings.KeyFieldName = "ID";
settings.Settings.ShowFilterRow = true;
asp-net-mvc-grid-export-hide-and-add-columns/CS/E4915/Controllers/HomeController.cs#L36
settings.KeyFieldName = "ProductID";
settings.Columns.Add("ProductID");
asp-net-mvc-grid-export-colored-grid-in-wysiwyg-mode/CS/Controllers/HomeController.cs#L47
settings.KeyFieldName = "ProductID";
settings.Settings.ShowFilterRow = true;
asp-net-mvc-grid-export-colored-grid-in-data-aware-mode/CS/Controllers/HomeController.cs#L57
settings.KeyFieldName = "ProductID";
settings.Settings.ShowFilterRow = true;
asp-net-mvc-grid-export-multiple-gridviews-into-a-document/VB/Controllers/HomeController.vb#L33
categoriesGridSettings.Name = "gvCategories"
categoriesGridSettings.KeyFieldName = "CategoryID"
categoriesGridSettings.Columns.Add("CategoryID")
mvc-gridview-export-data-to-different-formats/VB/Controllers/HomeController.vb#L54
settings.CallbackRouteValues = New With {.Controller = "Home", .Action = "TypedListDataBindingPartial"}
settings.KeyFieldName = "ID"
settings.Settings.ShowFilterRow = True
asp-net-mvc-grid-export-hide-and-add-columns/VB/E4915/Controllers/HomeController.vb#L37
settings.KeyFieldName = "ProductID"
asp-net-mvc-grid-export-colored-grid-in-wysiwyg-mode/VB/Controllers/HomeController.vb#L54
settings.KeyFieldName = "ProductID"
settings.Settings.ShowFilterRow = True
asp-net-mvc-grid-export-colored-grid-in-data-aware-mode/VB/Controllers/HomeController.vb#L66
settings.KeyFieldName = "ProductID"
settings.Settings.ShowFilterRow = True
See Also