I have a report that pulls a list of employees from a database, this database has URL links to an image of themselves. Users are not required to upload an image, therefore in some cases when trying to load an image there will be a 404 error. I am trying to set up the image element in the table to load the image if it exists and to take a local default image if there is a 404 error. I'm trying this expression in the ImageUrl Properties
if(isNull(fields.Picture),noImage.png,Fields.picture) <-- Not certain if the isNull is the method I should be using but I can't tell because I an encounter before it even runs.
this returns with an Unable to resolve expression type, unable to find context scope for Id<noImage>.Id<png>
Is it possible to do what I am trying to achieve within the Infragistics reporting?
You are missing a couple of commas, try with if(isNull(fields.Picture),"noImage.png",Fields.picture).
That works for getting to the image, the isNull portion does not though (If i flip the noImage.png and Fields.picture it will load the noImage). I guess because it get's a 404 error it does not necessarily mean it is null. Now I just need to figure out how to check if it is a 404 error.
If you are pulling the data from an object data source, you could add a method that checks for 404 and then call it with the expression language when binding to the ImageUrl property.
I am fairly new to using Visual Studio and MVC, so where exactly would this method be located? Would I implement this in to the igr files in some fashion, or would this method be located somewhere else? Thanks for your help so far!
Edit: I'm using a SQL Datasource so I'm not sure if your proposed approach would work, please correct me if I'm wrong.
So currently I have a static method that takes two parameters, first and last name. All this does is returns the proper URL from the list in an IENumerable because for some reason I can't seem to have the report viewer iterate through the IEnumerable with more than one "User". So currently I can have the Report Data Explorer load in the Object Data Source and then it asks me to choose what the arguments for the method should be. I'm not entirely sure which one to choose, I've tried the Set Constant Value where I fill in the Arguments Value with the =Fields.FirstName and =Fields.Surname to pass the first and last names. This does not seem to be the correct approach as it loads the default image, which is the case for when it cannot find a user. I also have tried the Dynamic Parameter but to no avail.
It works with a standard method and the static methods to prepare the IEnumerable of user urls. The only thing is the report viewer does not iterate through them. It constantly loads the first image for each row of the report.
Can you try creating a public and static method?
I have successfully gotten the class to be loaded in as an Object Data Source. The only issue is now that it only loads the first image of the List, in the expression do I have to have it iterate over the dataset?
I went into Data Source Configuration Wizard and selected the Object Data Source and I navigate to my buildUsers list and when I select it, it returns with this error: The selected type does not contain any public properties.
Any suggestions?
EDIT: The field in User that contains the URL is public.