Custom Column in TypedList

Posts   
 
    
MarkKilroy
User
Posts: 3
Joined: 24-Apr-2009
# Posted on: 24-Apr-2009 21:59:19   

I posted this as a response orginally I aplogize... I see where I can add a new custom column in a typed list between the // __LLBLGENPRO_USER_CODE_REGION_START InitClass sections.

I want to add a custom column that produces a formatted date string. I need this for the compact framework because the data grid (in compact framework) does not allow for formatting of the columns.

If I try something like: // __LLBLGENPRO_USER_CODE_REGION_START InitClass DataColumn SurveyDateFormatted = new DataColumn("SurveyDateFormatted", typeof(System.String), "CONVERT(NVARCHAR(10), surveydate, 101)"); SurveyDateFormatted.ReadOnly = true; this.Columns.Add(SurveyDateFormatted); // __LLBLGENPRO_USER_CODE_REGION_END

I get an error.

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 24-Apr-2009 23:47:25   

Hi Mark -

Not sure if this will help you or not... but I have added columns successfully in 2 different TypedLists of mine:

    Partial Public Class ContractBenefitTypedList

        Protected Overrides Sub OnInitialized()
            'Create custom column
            Dim colSummary As New DataColumn("Summary", GetType(String), "Benefit + ' (' + TPA + ')'", MappingType.Element)
            Me.Columns.Add(colSummary)

            'Call Base
            MyBase.OnInitialized()
        End Sub

    End Class
    Partial Public Class ReportYtdsummaryByGroupTypedList

        Protected Overrides Sub OnInitialized()
            'Create custom column - If IsIncome = True, Return Positive, Else = Return Negative
            Dim colIncomeExpenseAmount As New DataColumn("IncomeExpenseAmount", GetType(Decimal), "IIF( IncomeExpenseIsIncome = True, IncomeExpenseAmountABS, IncomeExpenseAmountABS * -1 )", MappingType.Element)
            Me.Columns.Add(colIncomeExpenseAmount)

            'Call Base
            MyBase.OnInitialized()
        End Sub

    End Class

Hope this helps!

Ryan

MarkKilroy
User
Posts: 3
Joined: 24-Apr-2009
# Posted on: 27-Apr-2009 18:44:58   

Thanks but that doesn't help. Once you try to use CONVERT(NVARCHAR(10), surveydate, 101) it fails. It doesn't matter if you add the column in the // __LLBLGENPRO_USER_CODE_REGION_START InitClass section or as a partial class.

In fact I do not see how you can add any column other than columns that exist in one of the tables. For example: If you wanted to add "NewText" to every row as a column (I don't know why you would... but for this example it makes sense). I understand how you concatenate but that is all.

Best regards, Mark Kilroy

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Apr-2009 05:51:37   

Hi Mark, this thread should be helpful to guide you on this: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8110

David Elizondo | LLBLGen Support Team