public Image Image { get; set; }
Image=(Image)randomImageFromCommentsClass.Image;
I get this:
Cannot convert System.Drawing.Image to System.Web.UI.WebControls
I think I imported the wrong namespace (System.Drawing)..That may be the mistake. What I am trying to do is to convert the Image type from database to an Image object.
public class Comments
{
public Image Image { get; set; }
Image = DBNull.Value.Equals(dr["Avatar"]) ? null: (Image)dr["Image"];
This image property above is from a different class code file in visual studio 2010.
Somehow the cast fails..how do i fix that?
There is definitely no way you will be able to cast unless the object you are casting is an instance of the other object.
You can covert the byte array to an Image with this snipet:
To show a dynamically created image with your WebControl you will need a handler more info here:
Serving Dynamic Content with HTTP Handlers