日期:2014-05-17 浏览次数:20343 次
<asp:Repeater ID="rptPhoto" runat="server" > <ItemTemplate> <li><asp:LinkButton runat="server" ID="lkbtn"> <asp:Image ID="imagephoto" Width="79" Height="79" ImageUrl='<%# "Getimage.ashx?ID="+ Eval("VolunteerID") %>' runat="server" /> </asp:LinkButton></li> </ItemTemplate> </asp:Repeater>
<%@ WebHandler Language="C#" CodeBehind="Getimage.ashx.cs" Class="CCWOnline.Management.Web.Getimage" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; using System.Configuration; using Siemens.WPV.Service; public class Getimage : IHttpHandler{ VolunteerService bll = new VolunteerService(); public void ProcessRequest(HttpContext context) { context.Response.ContentType = "image/jpeg"; int volunteerID = Int32.Parse(context.Request.QueryString["ID"]); SqlDataReader sdr = bll.FindByID(volunteerID); if (sdr.Read()) { context.Response.BinaryWrite( (byte[])dr["photo"] ); } sdr.Close(); } }