Image Handler Bind With Repeater

Posted by Dotnet4ashu under ASP.NET category on | Points: 40 | Views : 3272
Hello Experts

First you need to create a handler for making this...........
and in the Database you will create a new field name U_image and its datatype will be img in the running database

<%@ WebHandler Language="C#" Class="UserImage" %>

using System;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

public class UserImage : IHttpHandler {

public void ProcessRequest (HttpContext context)
Int64 imageid = Convert.ToInt64(context.Request.QueryString["userid"]);

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);


SqlCommand command = new SqlCommand("select U_image from User_Registration_Details where Userid=" + imageid, connection);

SqlDataReader dr = command.ExecuteReader();

if (dr.Read())

if (dr["U_image"] != DBNull.Value)



public bool IsReusable {
get {
return false;


Then on ASPX

<asp:Repeater ID="rpt_dealer" runat="server">

<table width="750" border="0" cellspacing="4" cellpadding="0">
<td colspan="2" class="main-head-txt">
<asp:Image ID="imgshow" runat="server" Width="74px" Height="60px" ImageUrl='<%#"UserImage.ashx?userid=" +Eval("UserId") %>'
onerror="this.onerror=null;this.src='images/user.gif';" AlternateText="Image not found" />

Comments or Responses

Posted by: T.Saravanan on: 3/4/2012 Level:Silver | Status: [Member] [MVP] | Points: 10

Kindly post your code inside the code tag.

Login to post response