Tuesday, March 20, 2012

Retrieving image from database

Dear Friends,

I have read many solution over the net, but since I am unable to utilize anyone according to my needs I am seeking help from you people.

I have a table imagedata in sql server 2005 having fields name and imageperson. Name is string and imageperson is Image field. I have successfully stored name of the person and his image in database.

I have populated the dataset from codebehind and bind it to the repeater.

By writing <%#DataBinder.Eval(Container.DataItem,"name")%>

I am a able to retrieve the name of the person. But when I pass photodata as

<%#photogen((DataBinder.Eval(Container.DataItem,"imageperson")))%>

where photogen is function in code behind having structure

public void photogen(byte[] dataretrieved)

{

Response.BinaryWrite(datarerieved)

}

But it is giving error at <%#photogen((DataBinder.Eval(Container.DataItem,"imageperson")))%>

The best overloaded method match for '_Default.photogen(byte[])' has some invalid arguments

AND

Cannot convert object to byte[].

Can anyone please provide me working solution with code for aspx page and code behind.

Thanks and regards

Have a look at the sample projects at:

http://www.codeproject.com/aspnet/EasyThumbs.asp

No comments:

Post a Comment