|
|
|
|
A unique LinqServerModeDataSource control was specifically designed by Developer Express for theASPxGridView, allowing it to efficiently work with large amounts of data by using LINQ Server Mode. In this mode, only small portions of the required data are loaded into the ASPxGridView by demand, and all the necessary data processing (such as grouping or sorting) is performed on the data server. This technique significantly reduces the application's response time. Previously, server mode was supported only for XPOdatasources; now, any LINQ query provider is also supported.
Test the application's performance by switching between two data sources and performing the same data operations (grouping or sorting) within the ASPxGridView control.
Description
I am using the ASPxGridView connected to the LinqServerModeDataSource. As you know, it does not allow us to edit data. However, I must support data editing. How this can be done?
Solution
This can be very easily implemented using the LinqServerModeDataSource, in conjunction with a companion DataSourceControl supporting data modification operations. First, we will explain how the ASPxGridView works. When the Update (Delete) button is clicked, a gridView calls the Update (Delete, Insert) command of its underlying DataSource. If you try to click this button when the ASPxGridView is connected to the LinqServerModeDataSource, the "Specified Method is Not Supported" exception will be triggered and the ASPxGridView will show you this text in the EditForm's error row. This happens because LINQ defines the query language. It does not define how data modifications should be performed.
The idea is simple - delegate data modification operations to the additional data source. I.e. you should
1) Handle the ASPxGridView's RowUpdating, RowInserting, RowDeleting events;
2) Prevent the ASPxGridView from trying to process modifications itself;
3) Delegate data modification operations to this additional data source.
2) Prevent the ASPxGridView from trying to process modifications itself;
3) Delegate data modification operations to this additional data source.
Here is the code showing how to implement data modifications, using the LinqDataSource ability to perform modifications for LinqToSql Linq implementation:
[C#]
protected void ASPxGridView1_RowUpdating(object sender,DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {
LinqDataSource1.Update(e.Keys, e.NewValues, e.OldValues);
e.Cancel = true;
ASPxGridView1.CancelEdit();
}
protected void ASPxGridView1_RowInserting(object sender,DevExpress.Web.Data.ASPxDataInsertingEventArgs e) {
LinqDataSource1.Insert(e.NewValues);
e.Cancel = true;
ASPxGridView1.CancelEdit();
}
protected void ASPxGridView1_RowDeleting(object sender,DevExpress.Web.Data.ASPxDataDeletingEventArgs e) {
LinqDataSource1.Delete(e.Keys, e.Values);
e.Cancel = true;
ASPxGridView1.CancelEdit();
}
Hiç yorum yok:
Yorum Gönder