Hi All,
Quick question here. I'm sure it's possilbe, just can't get it to work. I've got a gridview. In have a gridview. The gridview is bound to a list of my custom class. The class exposes a link to an image as well as the image's height and width. I have a Image Control in the gridview. I've bound the Image Url to the correct property. Now, I'd like to bind the height and width properties as well. But everytime I do that I get the following error:
Cannot create an object of type 'System.Web.UI.WebControls.Unit' from its string representation '"<%#Bind("GetImageHeight()")%' for the 'Height' property.
Here is an example of the tag:
<asp:Image runat="server" ID="imgProduct" ImageUrl='<%#Bind("ImageUrl")%>'
Height="<%#Bind("GetImageHeight()")%>" Width="<%#Bind("GetImageWidth()")%>">
</asp:Image>
So, in short... how to I bind properties which are not string?
Sample of methods GetImageHeight and GetImageWidth:
public Unit GetImageHeight()
{
Unit u = new Unit(Convert.ToString(ImageHeight) + "px");
return u;
}
public Unit GetImageWidth()
{
Unit u = new Unit(Convert.ToString(ImageWidth) + "px");
return u;
}