In a report I'm working on we want to display some images based on the value of a field. For that purpose I've created a UserFunction that grabs the image out of our embedded resource pack and returns it.
This is where things get a bit ugly.
Since this is a WPF app, we use BitmapImage for storing embedded image resources. It appears that the PictureBox doesn't support BitmapImage? The exception rendered in the Picturebox is "The given key was not present in the dictionary"
To avoid using BitmapImage I've tried returning the URI to the resource, also to no avail. The URI is prefixed with pack:// and that is apparently an unsupported prefix (according to the exception message.)
Going from BitmapImage to an actual GDI+ Image is not trivial since we're running a WPF app and I would really like to avoid doing that. Physical paths are also not an option...
Any ideas?
protected void BTN_Process_Click(object sender, EventArgs e) { ReportBook reportbook = new ReportBook(); ReportViewer1.Report = null; foreach (GridDataItem si in RG_Reports.SelectedItems) { string ReportName = si.OwnerTableView.DataKeyValues[si.ItemIndex]["Report"].ToString(); Type reportType = Type.GetType(Server.UrlDecode(ReportName)); Telerik.Reporting.Report report = (Telerik.Reporting.Report)Activator.CreateInstance(reportType); report.ReportParameters["Filter"].Value = Session["FilterTextAsset"]; report.ReportParameters["FilterExA"].Value = Session["FilterExA"]; report.ReportParameters["IsActive"].Value = Session["FilterIsCheckedAsset"]; report.ReportParameters["OrgUnitId"].Value = Request.QueryString["OrgUnitId"]; report.ReportParameters["AssetId"].Value = Request.QueryString["AssetId"]; report.ReportParameters["UserId"].Value = Session["UserId"]; report.ReportParameters["IsInStock"].Value = Session["FilterIsInStockAsset"]; report.ReportParameters["IsOrder"].Value = Session["FilterIsOrder"]; report.ReportParameters["Group1"].Value = new string[] { "" }; report.ReportParameters["Group2"].Value = new string[] { "" }; report.ReportParameters["Sort1"].Value = ""; report.ReportParameters["Sort2"].Value = ""; reportbook.Reports.Add(report); } if (RG_Reports.SelectedItems.Count != 0) { reportbook.DocumentName = "Assets"; ReportViewer1.Report = reportbook; } }Telerik.Reporting.TextBox txtGroupHeader = new Telerik.Reporting.TextBox(); Telerik.Reporting.TextBox txtGroupTotal;// = new Telerik.Reporting.TextBox(); toggleVisibilityAction1 = new Telerik.Reporting.ToggleVisibilityAction(); txtGroupHeader.Action = toggleVisibilityAction1; toggleVisibilityAction1.DisplayExpandedMark = false; // Required for telerik Reporting designer support
InitializeComponent(); TableGroup group = new TableGroup(); Telerik.Reporting.TableGroup tableGroup4 = new Telerik.Reporting.TableGroup(); Telerik.Reporting.TableGroup tableGroup5 = new Telerik.Reporting.TableGroup(); group.Name = "Season"; group.Groupings.AddRange(new Telerik.Reporting.Grouping[] { new Telerik.Reporting.Grouping("=Fields.Season")}); group.Sortings.AddRange(new Telerik.Reporting.Sorting[] { new Telerik.Reporting.Sorting("=Fields.Season", Telerik.Reporting.SortDirection.Asc)});
txtGroupHeader.Name = "txtGroupHeader"; txtGroupHeader.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(3.9314577579498291D), Telerik.Reporting.Drawing.Unit.Cm(0.43585944175720215D));<br> txtGroupHeader.Style.BackgroundColor = System.Drawing.Color.Red; txtGroupHeader.Style.BorderStyle.Bottom = Telerik.Reporting.Drawing.BorderType.Solid; txtGroupHeader.Style.Color = System.Drawing.Color.White; txtGroupHeader.Style.Font.Bold = true; txtGroupHeader.StyleName = ""; txtGroupHeader.Value = "=Fields.Season"; tableGroup4.Groupings.AddRange(new Telerik.Reporting.Grouping[] { new Telerik.Reporting.Grouping(null)}); group.Sortings.AddRange(new Telerik.Reporting.Sorting[] { new Telerik.Reporting.Sorting("=Fields.Season", Telerik.Reporting.SortDirection.Asc)}); tableGroup4.Name = "Details"; tableGroup5.Name = "Group1s"; //group.ChildGroups.Add(tableGroup4); //group.ChildGroups.Add(tableGroup5); //this.table1.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Cm(1)));<br> this.table1.Corner.SetCellContent(0, 0, txtGroupHeader); this.table1.Items.Add(txtGroupHeader); group.ReportItem = txtGroupHeader; //Remove the detail group TableGroup detailGroup = table1.RowGroups[0]; table1.RowGroups.Clear(); //detailGroup.Visible = false; toggleVisibilityAction1.Targets.AddRange(new Telerik.Reporting.IToggleVisibilityTarget[] { detailGroup}); //Add the detail group as a child to the AgeGroup (nest it) group.ChildGroups.Add(detailGroup); table1.RowGroups.Add(group)