Hi Guys,
I need to generate a default value for a BinaryImage (in a RadListView) when the image source from the database is NULL.
This is the BinaryImage code in RadListView
<asp:PlaceHolder ID="badgeContainer" runat="server"></asp:PlaceHolder> </LayoutTemplate> <ItemTemplate> <asp:LinkButton ID="lb1" runat="server" CommandName="content" CommandArgument='<%#Eval("bid") %>'> <telerik:RadBinaryImage ID="rbImageBadge" runat="server" DataValue='<%# IIf(Eval("badge") IsNot DBNull.Value, Eval("badge"), New System.Byte(-1) {})%>' AutoAdjustImageControlSize="false" Width="120px" Height="120px" ToolTip='<%#Eval("badgetitle", "{0}") %>' AlternateText='<%#Eval("badgetitle", "{0}") %>' /> </asp:LinkButton>''''''''''''''''''''''' etc
I have tried everything that I have read but just cannot get it to show a default image.
All help appreciated!
My Handler is
Imports System.Data.SqlClientPublic Class badgeImage : Implements IHttpHandler Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim conn As SqlConnection = Nothing conn = New SqlConnection(ConfigurationManager.ConnectionStrings("jbdata").ConnectionString) context.Response.ContentType = "image/png" Dim id As Integer = Convert.ToInt32(context.Request.QueryString("ID")) Dim cmdText As String = "select badge from badges where bid=" & id Dim command As New SqlCommand(cmdText, conn) conn.Open() Dim reader As SqlDataReader = command.ExecuteReader() reader.Read() If id > 0 Then Dim image As Byte() = DirectCast(reader(0), Byte()) context.Response.BinaryWrite(image) Else Dim location As String = System.Web.HttpContext.Current.Server.MapPath("~/badgz/images/default.png") System.Web.HttpContext.Current.Response.WriteFile(location) End If reader.Close() conn.Close() End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End PropertyEnd Class