RDLC报告显示没有绝对路径的照片

时间:2018-07-06 21:27:05

标签: asp.net-mvc rdlc

您好,我已经创建了RDLC报告,并将照片存储在数据库中的文件夹和路径中,但没有绝对路径。

如果我在rdlc报告图像中写入绝对路径,则可以正常工作,但我想知道如何在没有绝对路径的情况下仅使用文件夹名称和图像名称。图像文件夹位于项目主文件夹中。就像项目/照片一样。enter image description here

enter image description here

        private Context db = new Context();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                string id = Request["id"];
                string query = @"select StudentID,c.DocumentType as DocumentID,DocumentNumber,Name,NameDari,FatherName,FatherNameDari,MobileNumber,Photo,b.ClassName as ClassID,d.LocationName as LocationID,e.TeacherName as TeacherID,a.Term,a.Score from StudentsInfo a 
join Class b 
on a.ClassID=b.ClassID
join Document c
on c.DocumentID=a.DocumentID
join Location d
on d.LocationID=a.LocationID
join Teachers e
on e.TeacherID=a.TeacherID order by a.StudentID desc";
                var data = db.Database.SqlQuery<StudentsInfo>(query);
                ReportViewer1.SizeToReportContent = true;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("IDCards.rdlc");
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportDataSource ds = new ReportDataSource("DataSet1", data);
                ReportViewer1.LocalReport.DataSources.Add(ds);
                this.ReportViewer1.LocalReport.EnableExternalImages = true;
                ReportViewer1.LocalReport.Refresh();
            }

        }

0 个答案:

没有答案