- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Issue with LLBLGenProDataSource2 and Intersoftpt WebGrid v5 when using paging
Joined: 04-Apr-2007
When I turn custom paging on intersoftpt's WebGrid it fails at runtime claiming the LLBLGenDataSource2 (v2.0.0.0 from March 21st) does not support paging. I tested the LLBLGenDataSource2 with a normal datagrid with paging and everything worked normally. I also tested intersoftpt's webgrid with an objectdata source connected to a dataset with custom select and select count methods and everything worked fine there also. Is there any method that the object datasource has implemented that the llblgendatasource2 doesn't when paging is turned on? Thanks
Joined: 04-Apr-2007
Aurelien wrote:
Hi,
Did you set the LLBLGenDataSource2 EnablePaging property to True ? Can you post the LLBLGenDataSource2 declaration code ?
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" AllowAutoDataCaching="False" DataSourceID="LLBLGenProDataSource2_1"
Visible="false" Height="400px" UseDefaultStyle="True" Width="100%" OnRowChanged="WebGrid1_RowChanged"
OnExport="WebGrid1_Export" OnExportCompleted="WebGrid1_ExportCompleted">
<RootTable>
<Columns>
<ISWebGrid:WebGridColumn Caption="Name" DataMember="Name" ColumnType="Template" Name="Name"
Width="100px">
<CellTemplate>
<asp:HyperLink ID="HyperLink_Site" runat="server" Text='<%# Eval("Name") %>' NavigateUrl='<%# ICWeb.SiteNavigation.CreateNavigationLink(ICWeb.SiteNavigation.Navigation.server_view, Eval("Id").ToString()) %>'></asp:HyperLink>
</CellTemplate>
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Alias" DataMember="Srvalias" Name="Alias" Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Function" DataMember="Function" Name="Function"
Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Critical" DataMember="CriticalServer" Name="Critical"
Width="100px" Visible="False">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Site" DataMember="Site" Name="Site" ColumnType="Template"
Width="140px">
<CellTemplate>
<asp:HyperLink ID="HyperLink_Site" runat="server" Text='<%# Eval("Site") %>' NavigateUrl='<%# ICWeb.SiteNavigation.CreateNavigationLink(ICWeb.SiteNavigation.Navigation.site_view, Eval("Site").ToString()) %>'></asp:HyperLink>
</CellTemplate>
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="IP" DataMember="IP" Name="IP" Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Os Version" Visible="False" DataMember="Srvosver"
Name="Os Ver" Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Vendor" Visible="False" DataMember="Vendor" Name="Vendor"
Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Region" DataMember="Region" Name="Region" Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Country" DataMember="Cntrynm" Name="Country" Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="City" DataMember="Ctynm" Name="City" Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="SerialNumber" Visible="False" DataMember="Srvsn"
Name="SerialNumber" Width="100px">
</ISWebGrid:WebGridColumn>
</Columns>
</RootTable>
<LayoutSettings AllowColumnFreezing="Yes" AllowColumnMove="Yes" AllowExport="Yes"
AllowGrouping="No" AllowSelectColumns="Yes" AllowSorting="Yes" ApplyFiltersKey="Enter"
FilterBarVisible="False" PagingMode="VirtualLoad" VirtualLoadMode="Custom" RowChangedAction="OnTheFlyPostback" UseRelativePositioning="true"
RowHighlightType="BackgroundOnly" InProgressUIBehavior="ChangeCursorToHourGlass"
CellClickAction="NotSet">
<FreezePaneSettings AbsoluteScrolling="True" ShowInContextMenu="True" MaxFrozenColumns="2" />
<GroupByBox ContextMenu="false">
</GroupByBox>
</LayoutSettings>
</ISWebGrid:WebGrid>
</ContentTemplate>
</asp:UpdatePanel>
<asp:PlaceHolder ID="PlaceHolder_Error" runat="server"></asp:PlaceHolder>
<br />
</div>
<div class="footerbar">
</div>
</div>
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource2_1" runat="server" LivePersistence="False"
OnPerformGetDbCount="LLBLGenProDataSource2_1_PerformGetDbCount" OnPerformSelect="LLBLGenProDataSource2_1_PerformSelect"
CacheLocation="Session" AdapterTypeName="InfrastructureCentral.Halsits2DataProvider.DatabaseSpecific.DataAccessAdapter, InfrastructureCentral.Halsits2DataProviderDBSpecific"
DataContainerType="TypedList" TypedListTypeName="InfrastructureCentral.Halsits2DataProvider.TypedListClasses.ServerSearchTypedList, InfrastructureCentral.Halsits2DataProvider"
EnablePaging="True" >
</llblgenpro:LLBLGenProDataSource2>
PAGE BEHIND for DSCONTROL
protected void LLBLGenProDataSource2_1_PerformGetDbCount(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformGetDbCountEventArgs2 e)
{
if (Page.IsPostBack)
{
using (DataAccessAdapter _da = new DataAccessAdapter())
{
try
{
e.DbCount = _da.GetDbCount(e.ContainedCollection, e.Filter);
}
catch (Exception ex)
{
ExceptionPolicy.HandleException(ex, "GlobalExceptionLogger");
}
}
}
}
protected void LLBLGenProDataSource2_1_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
{
if (Page.IsPostBack)
{
using (DataAccessAdapter _da = new DataAccessAdapter())
{
try
{
_da.FetchTypedList(e.ContainedTypedList, e.Filter.PredicateExpression, e.PageSize, e.Sorter, true, e.PageNumber, e.PageSize);
}
catch (Exception ex)
{
ExceptionPolicy.HandleException(ex, "GlobalExceptionLogger");
}
}
}
}
Above is the declaration for the webgrid and the datasource control. In the page behind I implemented the performselect and the performgetdbcount.
Thanks
Joined: 04-Apr-2007
Aurelien wrote:
Hi,
mmm that wierd... can you post the error callstack ?
Server Error in '/' Application.
Invalid datasource control type for this operation. The WebGrid instance 'WebGrid1' is configured to use load on demand (VirtualPagingMode = Custom), however the assigned datasource control does not support Paging. Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid datasource control type for this operation. The WebGrid instance 'WebGrid1' is configured to use load on demand (VirtualPagingMode = Custom), however the assigned datasource control does not support Paging. Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Invalid datasource control type for this operation. The WebGrid instance 'WebGrid1' is configured to use load on demand (VirtualPagingMode = Custom), however the assigned datasource control does not support Paging. Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource.] ISNet.WebUI.WebGrid.WebGrid._BindDataSourceControl(Boolean forceBind) +951 ISNet.WebUI.WebGrid.WebGrid.BindDataSourceControl() +26 ISNet.WebUI.WebGrid.WebGrid.OnInitializeDataSource(Object dataSource) +967 ISNet.WebUI.WebGrid.WebGrid.OnLoad(EventArgs e) +236 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
I am having a difficult time catching the exception since it is happening when the control is created. Is it possible that the webgrid is looking for a specific method that isn't implemented by the LLBLGenDataSource control
Hi,
Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource.
it seems that WebGrid suports paging only with ObjectDataSource or ISDataSource, witch is specific to Intersoftpt : http://support.intersoftpt.com/docs/isdatasource/1.0.1500/ISNet.WebUI.ISDataSource~ISNet.WebUI.DataSource.ISDataSource.html
Joined: 04-Apr-2007
Aurelien wrote:
Hi,
Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource.
it seems that WebGrid suports paging only with ObjectDataSource or ISDataSource, witch is specific to Intersoftpt : http://support.intersoftpt.com/docs/isdatasource/1.0.1500/ISNet.WebUI.ISDataSource~ISNet.WebUI.DataSource.ISDataSource.html
The ISDataSource is specific to Intersoft however the objectdatasource isn't. The objectdatasource is shipped with .net and I thought that it was the datasource that the LLBLGenDataSource2 was created to use in the place of. When using .net's objectdatasource control I am able to implement paging in the webgrid correctly. Am I missing something?
Thanks Brandt
Joined: 04-Apr-2007
After looking at their code, it seems they check
if (!webGridDataSourceInfo.IsIntersoftDataSourceControl())
{
throw new InvalidOperationException("Invalid datasource control type for this operation. The WebGrid instance '" + this.ID + "' is configured to use load on demand (VirtualPagingMode = Custom), however the assigned datasource control does not support Paging. Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource.");
}
Sometimes I really wish that the 'developers' who write (web)grids first learn abit about OO principles like inheritance, polymorphism etc.. If they just use the base class 'DataSourceControl' then can do EVERYTHING with the datasource control and support EVERY datasource control out there...
Joined: 04-Apr-2007
Otis wrote:
Sometimes I really wish that the 'developers' who write (web)grids first learn abit about OO principles like inheritance, polymorphism etc.. If they just use the base class 'DataSourceControl' then can do EVERYTHING with the datasource control and support EVERY datasource control out there...
![]()
I agree. It is really frustrating. It seems their datasource control inherits from the objectdatasource control that comes with .net. When their webgrid's datasource is connected to an objectdatasource they will cast it to their own before they check. I guess this saves them the task of using reflection to check to see if the datasource supports the performselect and performselectcount(?) methods. Therefore when it gets the type of your datasource and doesn't look at the base type it assumes that the datasource does not implement paging. I have a support case open with them and hopefully they will take a look at the problem.
No these events are not necessary for the grid: a grid calls the datasourcecontrol (!)'s ExecuteSelect/Update/Insert/Delete methods. that's it. These methods are overriden in our control and raise the events PerformWork/Select etc. So all the grid should do is simply call Execute* methods and everything is OK and it will work with whatever subtype of DataSourceControl.
Joined: 04-Apr-2007
Otis wrote:
No these events are not necessary for the grid: a grid calls the datasourcecontrol (!)'s ExecuteSelect/Update/Insert/Delete methods. that's it. These methods are overriden in our control and raise the events PerformWork/Select etc. So all the grid should do is simply call Execute* methods and everything is OK and it will work with whatever subtype of DataSourceControl.
Your correct. I have reflected to much code today.
Joined: 04-Apr-2007
I went a little deeper into the code and found the problem. I have quoted the email I sent to their support below. Can you think of any way around this.
I found the problem with the webgrid code and why the webgrid will only support the ISDataSource and the ObjectDataSource. No other datasource other than those two will work when custom paging is turned on because of the code below. The DataSourceView is the common class and the inherited class that all derived classes use including the one LLBLGenDataSource and also your own ISDataSourceView use. When the DataSourceView (data) returns true for both CanPage and CanRetrieveTotalRowCount, you check to see if the DataSourceView is an ObjectDataSourceView. If it isn’t then you check to see if the datasource is actually your own control !info.IsIntersoftDataSourceControl(). If it is not then your throw an exception. What I don’t understand is why you even want to cast to an ObjectDataSourceView because it only overrides the members that are already present in the DataSourceView base class. Even if was to inherit directly from the ObjectDataSourceView in a class called MyObjectDataSourceView, the code “if (data is ObjectDataSourceView)” would still return false because MyObjectDataSourceView is not an ObjectDataSourceView. Only the base class is. FYI, the LBLLGenDataSource2 inherits from LLBLGenDataSource2BaseClass which inturns inherits from DataSourceView. So just adding if (data.GetType().BaseType is DataSourceView || data is DataSourceView) will not work.
DataSourceView data;
ObjectDataSourceView view2;
……
if (data.CanPage && data.CanRetrieveTotalRowCount)
{
info.get_SelectArguments().StartRowIndex = this._dataBinding.?;
info.get_SelectArguments().MaximumRows = this.LayoutSettings.VirtualPageSize;
if (data is ObjectDataSourceView)
{
view2 = data as ObjectDataSourceView;
info.set_IgnoreDataSourceViewChanged(true);
if (8 != 0)
{
if ((0 == 0) && (view2.SelectParameters["sortExpression"] == null))
{
goto Label_02B3;
}
view2.SelectParameters.Remove(view2.SelectParameters["sortExpression"]);
}
goto Label_029C;
}
goto Label_022F;
}
……..
Label_022F:
if (!info.IsIntersoftDataSourceControl())
{
if (7 != 0)
{
throw new InvalidOperationException("Invalid datasource control type for this operation. The WebGrid instance '" + this.ID + "' is configured to use load on demand (VirtualPagingMode = Custom), however the assigned datasource control does not support Paging. Please use datasource control type that support Paging such as ObjectDataSource or ISDataSource.");
}
goto Label_0159;
}
I don't see a way around this.
BTW: I think the following statement might be false:
Even if was to inherit directly from the ObjectDataSourceView in a class called MyObjectDataSourceView, the code “if (data is ObjectDataSourceView)” would still return false because MyObjectDataSourceView is not an ObjectDataSourceView
Joined: 04-Apr-2007
Walaa wrote:
I don't see a way around this.
BTW: I think the following statement might be false:
Even if was to inherit directly from the ObjectDataSourceView in a class called MyObjectDataSourceView, the code “if (data is ObjectDataSourceView)” would still return false because MyObjectDataSourceView is not an ObjectDataSourceView
Your right. The is operator is returning true for the base type. I will need to reread my Effective C# book.