Thursday, January 1, 2015

RDLC Report GetData and SetData standard method



  • Add the following function in report code




























public Shared CompanyAddressInfo as Object

Public Function SetData(NewData as Object,Group as Integer)
    if Group = 1 and  NewData > "" then
       CompanyAddressInfo = NewData
    End if 
End Function

Public Function GetData(Num as integer,Group as Integer) as Object
    if Group = 1 then
       if Choose(Num, Split(Cstr(CompanyAddressInfo), Chr(177)))="" then
          Return " "
       End if
       Return Cstr(Choose(Num, Split(Cstr(CompanyAddressInfo), Chr(177))))
    End if
End Function


  • In Report Body – create the textbox and call the setdata function from hidden expression of textbox









































=Code.SetData(Cstr(Fields!CompanyAddress1.Value) + Chr(177) +
Cstr(Fields!CompanyAddress2.Value) + Chr(177) +
Cstr(Fields!CompanyAddress3.Value) + Chr(177) +
Cstr(Fields!TaxIdentTypeCaption.Value)
, 1)

  • Now just direct use the GetData function in report Header and Footer to get the value of index data.(Note: there is no need to create SetData function in report header as we do in old version report)



























=Code.GetData(82,1)

  

  • For Image Box = There is no need to create SetPicture and GetPicture function in report to print logo.You can directly use the field expression in report header and footer to print logo


























=Convert.ToBase64String(Fields!CompanyInfo2Picture.Value)

4 comments:

  1. Thank You for this article and the description of this issue :) Really interesting and good read :)

    ReplyDelete
  2. Hi Nilesh,

    Thank you for nice post. I tried printing logo by convert.tobase64string codeline... But it didn't work. Cross mark came in RTC report.

    I am using Nav 2016.

    ReplyDelete
  3. Hi,I want to create index for report.In my report there are more than 30 pages.The report has multiple dynamic processes like for one process consumes 5 pages another process contains 8 pages and so on. I want create index on first page that has content fields are processno,processname and pageno.
    Please help me to solve the problem i'm stucked with this point from last 5 days.

    ReplyDelete