I am using LLBLGen Pro v2.0. The SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll version is 2.0.0.060921.
I'm having an issue with the LLBLGenProDataSource2 control and an ASP.NET 2.0 DataList control.
I'm using the data source control with LivePersistence set to false and EnableViewState set to false. When the page loads initially everything works as I would expect with the PerformSelect event firing after all the page/user control load events. But when a post back happens after clicking a button in the browser the PerformSelect event occurs before any load/click events happen.
I tried to figure out what might be causing this, and I narrowed it down. If the DataList ItemTemplate contains a TextBox control then the PerformSelect event fires before I would expect. If I take out the TextBox control and leave just Label controls then the PerformSelect fires after the page load event.
I created a scaled down example of the code that is having the problem.
The ASP.NET page source:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestEvents.aspx.vb" Inherits="TestEvents" %>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataSourceID="ds2" EnableViewState="False">
<ItemTemplate>
WarnIfNoModel:
<asp:Label ID="WarnIfNoModelLabel" runat="server" Text='<%# Eval("WarnIfNoModel") %>'>
</asp:Label><br />
<asp:TextBox ID="txt1" runat="server" />
<br />
</ItemTemplate>
</asp:DataList>
<llblgenpro:LLBLGenProDataSource2 ID="ds2" runat="server" DataContainerType="TypedView"
EnableViewState="False" LivePersistence="False" TypedViewTypeName="Lib.Entities.TypedViewClasses.PartSearchResultsTypedView, Lib.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce571910e9bd08c9">
</llblgenpro:LLBLGenProDataSource2>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
The code behind:
Imports Lib.Controllers
Partial Class TestEvents
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub ds2_PerformSelect(ByVal sender As Object, ByVal e As SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2) Handles ds2.PerformSelect
ds2.TypedView = New SearchController().GetSearchResults(29)
End Sub
End Class
With the TextBox control in the DataList the ds2_PerformSelect is fired before Page_Load and Button1_Click. If you take out the TextBox control then the ds2_PerformSelect fires after Page_Load and Button1_Click. This causes a problem in the actual code because I am initializing some values in the Load events that is needed by the PerformSelect event.
I am getting around this problem by ignoring the initial PerformSelect if Page_Load hasn't occurred, then call Select on the data source after processing the click event. The problem is I'm not sure if this might cause other issues that I haven't found yet.
I certainly could be doing something wrong, but it seems like a possible bug with either LLBLGen or probably more likly Microsoft or me
If I need to provide any more information, please let me know.
Thank you!