locked
How to get web.config value in RDLC report ? RRS feed

  • Question

  • User-1034565261 posted

    I am generating a rdlc report.

    Problem : In one of my text boxes on report i show "first name"  of customer, but if this field is empty then i want to show a value defined in my web.config file.

    Any clues how can i fetch a value from web.config file inside a rdlc report. and then conditionally assign it to that textbox .

    Monday, March 12, 2007 8:08 AM

Answers

  • User256182628 posted
    You need to pass the value as a parameter to the report.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 12, 2007 2:35 PM
  • User-1034565261 posted

    thanks for the reply

    i solved the problem by writing a function in code tab.

    You can write vb code in the code tab of report.. Report >> Report properties >>code..

    and that function can then be accessed the using code.functionName() 

    :)

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 13, 2007 12:56 PM
  • User1520651454 posted

    i am trying to do the same thing. can you provide a sample of how you assigned a value from the web.config into the report. Im having some trouble writing the code in the Report Code window.

    is it VBScript? or can i use C#?

    thanks,

    mcm

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2007 9:14 PM
  • User-1034565261 posted

    you have to write vb.net code ........with proper refrences to the namespaces used..

    for getting web.config values ..its same as u get on any other page(configurationsettings.appsettings......)

    write a function in code window and specify its return type as string (return web.config value from this function)

    now you can call this function from ur report and get that value....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 30, 2007 7:09 AM

All replies

  • User256182628 posted
    You need to pass the value as a parameter to the report.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 12, 2007 2:35 PM
  • User-1034565261 posted

    thanks for the reply

    i solved the problem by writing a function in code tab.

    You can write vb code in the code tab of report.. Report >> Report properties >>code..

    and that function can then be accessed the using code.functionName() 

    :)

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 13, 2007 12:56 PM
  • User1520651454 posted

    i am trying to do the same thing. can you provide a sample of how you assigned a value from the web.config into the report. Im having some trouble writing the code in the Report Code window.

    is it VBScript? or can i use C#?

    thanks,

    mcm

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2007 9:14 PM
  • User-1034565261 posted

    you have to write vb.net code ........with proper refrences to the namespaces used..

    for getting web.config values ..its same as u get on any other page(configurationsettings.appsettings......)

    write a function in code window and specify its return type as string (return web.config value from this function)

    now you can call this function from ur report and get that value....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 30, 2007 7:09 AM
  • User1387823840 posted

    Hi I am facing smae problem i want to show external image whose path is stored in web config i have used following code in custom rdlc code

    Public Function GetUrl() as String
     
    Dim rootWebConfig1 As System.Configuration.Configuration
    rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Nothing)
     Dim customSetting As System.Configuration.KeyValueConfigurationElement
        customSetting = rootWebConfig1.AppSettings.Settings("servername")
     
    Return   customSetting.Value.ToString()
     
    End Function
    and using it in image expression as
    =Code.GetUrl()
    And web config settings are

    <appSettings>

    <add key="servername" value="Here is path of my image"/>


    </appSettings>

    But i am not geeting image when i run my rdlc file please tell me where i am wrong.
    Thursday, April 4, 2013 2:48 AM