Back to Devexpress

ASPxGridBase.ForceDataRowType(Type) Method

aspnet-devexpress-dot-web-dot-aspxgridbase-dot-forcedatarowtype-x28-system-dot-type-x29.md

latest3.4 KB
Original Source

ASPxGridBase.ForceDataRowType(Type) Method

Informs the grid control about the type of objects contained within its data source.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public void ForceDataRowType(
    Type type
)
vb
Public Sub ForceDataRowType(
    type As Type
)

Parameters

NameTypeDescription
typeType

The type of data source records.

|

Remarks

If the grid’s data source is not empty on the first load, the grid automatically determines and saves the type of objects contained within its data source, so you do not have to force the type of objects contained within its data source.

If the grid’s data source is empty (e.g., because of an invalid filter expression or empty data base) on the first load, use the ForceDataRowType method to inform the ASPxGridView control about the types of its columns.

csharp
protected void ASPxGridView1_Init(object sender, EventArgs e) {
    ASPxGridView1.ForceDataRowType(typeof(MyDataObject));
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ForceDataRowType(Type) 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-entitydatasource-and-common-scenarios/CS/GridEntityFramework/MasterDetail.aspx.cs#L29

csharp
protected void gridMaster_DataBinding(object sender, EventArgs e) {
    gridMaster.ForceDataRowType(typeof(Category));
    gridMaster.DataSource = DataContext.Categories.ToList();

asp-net-web-forms-grid-entitydatasource-and-common-scenarios/VB/GridEntityFramework/MasterDetail.aspx.vb#L31

vb
Protected Sub gridMaster_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
    gridMaster.ForceDataRowType(GetType(Category))
    gridMaster.DataSource = DataContext.Categories.ToList()

See Also

Code central example E3251

Grid View

ASPxGridBase Class

ASPxGridBase Members

DevExpress.Web Namespace