Modify field contents in TypedList

Posts   
 
    
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 02-Jun-2006 20:44:05   

OK, so now I have : Private Shadows Sub OnResultsetBuilt(ByVal toReturn As ResultsetFields)

    End Sub

What I want to do is change the content of one field ("ImageURL") through a function ("GenerateImageURL(isbn)") to a different value in every entity in the result set. How do I spin through the entities to accomplish this?

Thanksdisappointed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 02-Jun-2006 21:01:14   

This method is called after the fields list has been created which is used to fetch the typedlist. So if you want to apply a function to a set of fields after the typedlist is fetched, you should simply call that function by passing the typedlist and in that function traverse the typedlist's data and apply the logic you want to apply.

Frans Bouma | Lead developer LLBLGen Pro
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 02-Jun-2006 22:45:13   

Otis wrote:

This method is called after the fields list has been created which is used to fetch the typedlist. So if you want to apply a function to a set of fields after the typedlist is fetched, you should simply call that function by passing the typedlist and in that function traverse the typedlist's data and apply the logic you want to apply.

Do I call that method from OnResultsetBuilt, is the result set fully populated at this time?

Thanks

Glenn

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 03-Jun-2006 03:18:28   

No, the OnResultsetBuilt is called after the fields list is created so there is no data in the typedlist. I believe that Frans was suggesting that you create you method to accept the typedlist and isbn and then process the passed typedlist with your logic to replace the image column.

glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 04-Jun-2006 13:21:45   

When I try to update the ImageUrl column I find that it is readonly and I cannot modify it's content.

        
Public Overrides Function Fill(ByVal maxNumberOfItemsToReturn As Long, ByVal sortClauses As ISortExpression, ByVal allowDuplicates As Boolean, ByVal selectFilter As IPredicate, ByVal transactionToUse As ITransaction, ByVal groupByClause As IGroupByCollection, ByVal pageNumber As Integer, ByVal pageSize As Integer) As Boolean
            Dim llok As Boolean = False
            llok = MyBase.Fill(maxNumberOfItemsToReturn, sortClauses, allowDuplicates, selectFilter, transactionToUse, groupByClause, pageNumber, pageSize)
            Me.FillImages()
            Return llok
        End Function

        Private Sub FillImages()
            Dim i As Integer = 0
            For i = 0 To Me.Count - 1
                Me(i).Imageurl = oAws.FindImage(Me(i).Sku1)
            Next
        End Sub

System.Data.ReadOnlyException was unhandled by user code Message="Column 'Imageurl' is read only." Source="System.Data" StackTrace: at System.Data.DataRow.set_Item(DataColumn column, Object value) at AWS2_DAL.TypedListClasses.InvListRow.set_Imageurl(String Value) in M:\Projects\AWS2\TypedListClasses\InvListTypedList.vb:line 1751 at AWS2_DAL.TypedListClasses.InvList.FillImages() in M:\Projects\AWS2\InvList.vb:line 313 at AWS2_DAL.TypedListClasses.InvList.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IPredicate selectFilter, ITransaction transactionToUse, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) in M:\Projects\AWS2\InvList.vb:line 306 at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView.ExecuteSelectTypedList(Int32 pageSize, Int32 pageNumber, DataSourceSelectArguments arguments) at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at System.Web.UI.WebControls.GridView.DataBind() at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

bclubb wrote:

No, the OnResultsetBuilt is called after the fields list is created so there is no data in the typedlist. I believe that Frans was suggesting that you create you method to accept the typedlist and isbn and then process the passed typedlist with your logic to replace the image column.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 04-Jun-2006 18:45:00   

Seems like the column is set by default to readonly. Please try and override this by overriding the OnInitialized method.

glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 05-Jun-2006 17:34:39   

Thanks for all the help. I finally implemented this behavior with the following technique:


        Public Overrides Function Fill(ByVal maxNumberOfItemsToReturn As Long, ByVal sortClauses As ISortExpression, ByVal allowDuplicates As Boolean, ByVal selectFilter As IPredicate, ByVal transactionToUse As ITransaction, ByVal groupByClause As IGroupByCollection, ByVal pageNumber As Integer, ByVal pageSize As Integer) As Boolean
            Dim llok As Boolean = False
            llok = MyBase.Fill(maxNumberOfItemsToReturn, sortClauses, allowDuplicates, selectFilter, transactionToUse, groupByClause, pageNumber, pageSize)
            If llok Then
                Me.Columns("Imageurl").ReadOnly = False
                Me.FillImages()
                Me.Columns("Imageurl").ReadOnly = True
            End If
            Return llok
        End Function

Glennsmile