【问题标题】:External image in report rdlc报告 rdlc 中的外部图像
【发布时间】:2015-09-11 07:53:12
【问题描述】:

我将图像上传到服务器并将它们的路径存储在表中 (varchar(MAX))。

我设法创建了一个报告并显示了该表中的记录,但我无法将图像绑定到它的数据源(存储路径)。

我的路径是这样的:

~/ARTSQLDATA/PTDIR/15090248/IDFTO/15090248PPID.jpg

我正在使用以下代码来填充我的数据集

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
        RepVuerCtl.ProcessingMode = ProcessingMode.Local
        RepVuerCtl.LocalReport.ReportPath = Server.MapPath("~/Account/RepPtProf.rdlc")
        RepVuerCtl.LocalReport.EnableExternalImages = True
        Dim DsPtProf As DSPtProf = GetData()
        Dim datasource As New ReportDataSource("PatientProfile", DsPtProf.Tables(0))
        RepVuerCtl.LocalReport.DataSources.Clear()
        RepVuerCtl.LocalReport.DataSources.Add(datasource)
    End If
End Sub
Private Function GetData() As DSPtProf
    Dim ARTSQLCON As SqlConnection = New SqlConnection(-------())
    Dim SQLCmd As New SqlCommand()
    SQLCmd.Connection = ARTSQLCON
    Using DtaRdr As New SqlDataAdapter(SQLCmd)
        SQLCmd.CommandType = CommandType.StoredProcedure
        SQLCmd.CommandText = "RepTblRegPtProf"
        SQLCmd.Parameters.Add("@FileNum", SqlDbType.Int).Value = 15090248 
        Using DsPtProf As New DSPtProf()
            DtaRdr.Fill(DsPtProf, "RepTblRegPtProf")
            Return DsPtProf
        End Using
    End Using

End Function

请帮忙 谢谢!

【问题讨论】:

    标签: asp.net vb.net sqldataadapter dynamic-rdlc-generation


    【解决方案1】:

    我找到了一个想要与您分享的解决方案,我很想听听您的反馈,

    我修改了我的上传功能,以 URI 格式保存图像路径(编码) (即..

    Dim ImgURI As String = New Uri(Server.MapPath("URL String")).AbsoluteUri    
    

    为了在 webform 上显示图像,我将 URI 解码为 URL

    Function ConvertURI(URI As String)
        Dim DecodeURI As String = HttpUtility.UrlDecode(URI) 'Decode URI string
        Dim SubURI = DecodeURI.Substring(DecodeURI.IndexOf("Your Folder"))
        Dim URL As String = "~/" & SubURI ' Restore the URL string format
        Return URL
    End Function
    ' then in your code
    
    Dim ImgURL as string = ConvertURI("Your URI")
    Sampleimg.ImageUrl = ImgURL
    

    要在 RDLC 报告中显示图像,只需将图像控制源设置为外部并将图像值分配给表中的字段值 非常感谢您的反馈, 谢谢!

    【讨论】:

      猜你喜欢
      • 2015-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-22
      • 2011-05-19
      • 1970-01-01
      相关资源
      最近更新 更多