Вы можете создать страницу HttpHandler (ashx), которая будет принимать строку запроса и устанавливать ее в качестве свойства imageUrl элемента управления изображением
<asp:image id="imgEmployee" imageUrl="DisplayImage.ashx?employeeId=<someId>"/>
Теперь в DisplayImage.ashx вы можете переопределить запрос процесса, как показано ниже: -
public void ProcessRequest (HttpContext context)
{
int employeeId;
if (context.Request.QueryString["employeeId"] != null)
employeeId = Convert.ToInt32(context.Request.QueryString["employeeId"]);
else
throw new ArgumentException("No parameter specified");
byte[] imageData= ;// get the image data from the database using the employeeId Querystring
Response.ContentType = "image/jpeg"; // You can retrieve this also from the database
Response.BinaryWrite(imageData);
}
Изменения в Web.config: -
<httpHandlers>
<add verb="*" path="img/*" type="DisplayImage"/>
</httpHandlers>
Подробности здесь и здесь .
Надеюсь, это поможет ..