Concatinating items

Concatinating items

Forum member · Sep 3, 2008
I am using a dplx and I have a name field that I need to show as LastName, FirstName. I am using a record area and putting in #LNmS1#, #FNmS1# in the text property. Which works just fine if there is a name. the problem is that if there is no data in those fields I'm left with a comma showing. How do I get it to not show the comma if there is no LastName.

Re: Concatinating items

Support · Sep 4, 2008
Hello, You will see the comma even if you do not have the data because you are adding it in the designer. If you want to show this only when there is data then you will have to use the LaidOut event of the placeholder. You can check the data before adding it to the report. You will have to add a placeholder in the designer. You can refer to the handling events topic on our help documentation. Thanks, ceTe Software Support Team.

Re: Concatinating items

Forum member · Sep 5, 2008
Well I've tried seting this up per the example and I get an error. the error is a NullReferenceException, Object reference not set to an instance of an object. I get it on the AddHandler pName1.LaidOut, AddressOf pName1_LaidOut line. when I look at the pName1 object it is nothing. I am using a dplx and I have added a placeholder to it with an ID of pName1. In the data I have two fields one LNmS1 and FNmS1 which I want to put together in the placeholder with a comma seperating them. So I need to get the underlying data and find out if there is a name then fill the placeholder Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim parameters As ParameterDictionary = New ParameterDictionary() Parameters.Add("@SchlYr", "0809") Parameters.Add("@StartDtTxt", "") Parameters.Add("@EndDtTxt", "") Parameters.Add("@AppUsrInstID", "1894") parameters.Add("@ReturnCnt", "2") Parameters.Add("@ReturnTyp", "P") Dim reportDocument As New DocumentLayout(Server.MapPath("/") & "ExamplesNet2\FandRappsPDF.aspx.dplx") Dim doc As New Document Dim pName1 As PlaceHolder = CType(reportDocument.GetReportElementById("pName1"), PlaceHolder) AddHandler pName1.LaidOut, AddressOf pName1_LaidOut doc = reportDocument.Run(parameters) doc.DrawToWeb("FoodStampsPDF.pdf") End sub

Re: Concatinating items

Support · Sep 5, 2008
Hello, You will have to make sure that the values that you get from the database are not null. If they are null make sure to replace them with empty strings. You will have to keep a check for null values. That will likely solve your problem. Thanks, ceTe Software Support Team

Re: Concatinating items

Forum member · Sep 5, 2008
I don't think the line Dim pName1 As PlaceHolder = CType(reportDocument.GetReportElementById("pName1"), PlaceHolder) has anything to do with the data does it. isn't if finding the placeholder in the document. well my pName1 is still set to nothing after the call so it never found the placeholder. Then my question would be how do I get the underlying data.

Re: Concatinating items

Support · Sep 8, 2008
Hello, Please make sure that you have a placeholder with the name pName1 in your designer. That line should get the placeholder element. We are able to run a similar test case without any problem. Dim layout As New DocumentLayout("C:\Temp\report.dplx") Dim placeHolder As PlaceHolder = CType(layout.GetReportElementById("Placeholder1"), PlaceHolder) AddHandler placeHolder.LaidOut, AddressOf placeHolder_LaidOut Dim doc As Document = layout.Run() doc.DrawToWeb() The above code gets the placeholder element and adds the handler. Following is the function gets called for this event. Public Sub placeHolder_LaidOut(ByVal sender As Object, ByVal e As PlaceHolderLaidOutEventArgs) Dim firstName As ceTe.DynamicPDF.PageElements.Label = New ceTe.DynamicPDF.PageElements.Label(e.LayoutWriter.RecordSets.Current("NameTwo").ToString(), 0, 0, e.ContentArea.Width, e.ContentArea.Height) e.ContentArea.Add(firstName) End Sub The "e.LayoutWriter.RecordSets.Current("NameTwo").ToString()" gives the current value for the NameTwo field from the table. Depending on this value you can do modifications to the data or you can add elements to the placeholder. Thanks, ceTe Software Support Team.