.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Display image icon in HyperLinkField of Gridview

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :ASP.Net
 Hello everyone! Can someone please tell me how to display an image in a HyperLinkField of a gridview?  Instead of words, I just want to show a simple little icon that can be clicked on and pass a query string to the next page.  The first hyperlink field I have set up works perfectly and passes the querystring to the next page.   The second hyperlinkfield is my attempt at showing the image but it's giving me a squiggly and telling me "the element img cannot be nested within the element hyperlinkfield" I got this technique from this brief article   - I would like to accomplish exactly what it says it is suppose to do. Thanks!   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="clientID"> <Columns> <asp:BoundField DataField="clientFirstName" HeaderText="First Name" /> <asp:BoundField DataField="clientLastName" HeaderText="Last Name" /> <asp:HyperLinkField HeaderText="More Info" Text="View more info..." DataNavigateUrlFields="clientID" DataNavigateUrlFormatString="Cli

View Complete Post

More Related Resource Links

display an icon in gridview - selectively


I've created an ExpenseReport application which allows users to attach receipts to Expense Report Lineitems. These are contained in a gridview using a template field:

<asp:TemplateField HeaderText="File" InsertVisible="False">
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:HyperLink ID="HyperLink" ImageUrl='<%# Eval("filename", "~/workflow/Images/attachment.jpg") %>'
                runat="server" NavigateUrl='<%# Eval("filename", "http://workflowserver/AtWork/workflow/ExpenseReport/retrieveattachment.aspx?attachment={0}") %>' Text="" />  

The trouble I have is that the 'attachment.jpg' icon shows for every lineitem (even one that does not contain an attachment).

I would like to be able to selectively display this icon or show a different icon if there is NO attachment.

Any suggestions would be greatly appreciated. I'm kind of stuck... ;-)

Thank You.

How To display image in GridView as hyperlink


Hello Everyone 

Could someone please help me with a little issue....

I was able to save the image in the database as binary....... but now i don´t know how to display it in the GridView as a hyperlink.

I´ve read something about ImageField..... I´d appreciate any help .


display image in gridview - unlucky with tutorials

I'm trying to display images in a gridview, but after following the examples of maybe 7 different tutorials I still haven't succeded. There are always some things that go unexplained. My latest attempt is according to this tutorial:http://www.aspdotnetcodes.com/Insert_Images_Database.aspxProblem No1: what exactly should I write in my ashx-file? Following the example in the tutorial this is the code so far:<%@ WebHandler Language="C#" Class="ImageHandler" %> using System; using System.Web; using System.Configuration; using System.Data.SqlClient; public void ProcessRequest (HttpContext context) { SqlConnection myConnection = new SqlConnection("DBPejganConnectionString1"); myConnection.Open(); string sql = "Select Image_Content, Image_Type from ImageGallery where Img_Id=@ID"; SqlCommand cmd = new SqlCommand(sql, myConnection); cmd.Parameters.Add("@ID", SqlDbType.Int).Value = context.Request.QueryString["id"]; cmd.Prepare(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); context.Response.ContentType = dr["BildTyp"].ToString(); context.Response.BinaryWrite((byte[])dr["BildData"]); dr.Close(); myConnection.Close(); }Please give me a hint (or rather the answer) on what's missing. The rest of the problems comes later... :)

Up Down GridView Icon Image for Column Sorting

I'm trying to add an Ascending and Descending sort direction Icon Image next to the header text of my ASP.NET 2.0 Gridview Columns.I've searched and found some examples that seem to do this but have had difficult time recoding them from C# to VB or some just seemed overly complex for what I want to do.Does anyone have a simple VB solution for sort icons?Thanks,Ethan   

GridView inline Master/Detail record display

This code drop is part of a smash and grab series. If you're in a rush, you can just grab this code and insert it into your application, no understanding is required. When you have some time (ya, right) you may want to review the source code.

Display data in gridview dynamicallay

I have AD domain which has 100000 users, I want to display all the users in gridview controls.Actually it is displaying users in gridview after parsing entire domain which takes around 30 min. I want to display the users while loading itself.It is continously getting user information from AD domain and getting each user details, I want to display the users information which already queried instead of waiting till getting all users information

asp.net display data in gridview

i want to display data in gridview binded to a sql datasource
but the problem part is i want to bind a field of that datasource to a dropdownlist and when a item is selected in that dropdownlist then correcposnding to that data will be displayed in gridview...

display data into GridView from excel sheet

I have to display data from excel sheet into my gridview and also I need to figure out a way to store data into excel files from my web page. I am using C# 3.5, VS 2008.

Display Related Data in an ASP.NET GridView

Typically when you display a datagrid you will want to show data from a related table. There are 3 different ways to accomplish this with NetTiers. You can use a custom stored procedure, deepload functionality from the code behind, or a strongly typed datasource control. We'll provide an example of each

Can't display an image from the database



My database has a products table that has images stored in a varbinary(MAX) column.

I'm trying to display product information in a repeater and trying to display the images as well by using a GenericHandler class but I can't get the image to show up in my page.

Here is my Handler.ashx class:

Public Class Handler
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        '== Set up the response settings
        context.Response.ContentType = "image/gif"
        context.Response.BufferOutput = False

        Dim id As Integer = -1
        Dim stream As Stream = Nothing
        If Not String.IsNullOrEmpty(context.Request.QueryString("id")) Then
            id = context.Request.QueryString("id")
            stream = GetImage(id)
        End If

        Const buffersize As Integer = 1024 * 16
        Dim buffer(buffersize) As Byte
        'byte[] buffer = new byte[buffersize];
        Dim count As Integer = stream.Read(buffer, 0, buffersize)

        While count > 0
            context.Response.OutputStream.Write(buffer, 0, count)
            count = stream.Read(buffer, 0, buffersize)
        End While


Session problem with display of image in row of reportviewer


Hello techies...

I am new to this sql reporting service. But anyhow by surfing I am able to bind the report but i was stuck in image display.

Anyways, i also managed that. But the real problem is whenever i was keeping a image control in rdlc report i was having session prob. If i remove the image control then as usual report works fine.

Please suggest me some solution.... either for session problem or for image display. I am keeping the image name in database but for binding the rdlc report i am using a store procedure which return the path (static) concating with the image name(kept in database).

Hope to find a solution .....

Cannot Display Image in Report


 I have a report using an image control that needs to display an image inside subfolder "Images\InstitutionLogos\".

On properties of image control i have the following properties set:

MIMEType= "image/png"

Source      = Database

Value        ="\Images\InstitutionLogos\" +Fields!InstitutionID.Value+".png"

Inside subfolder "Images\InstitutionLogos\" each image is named with a number which represents Fields!InstitutionID.,(ex, 1.png, 2.png, 10.png)

However, when i run the report the image just displays an X, what am i missing?

Gridview with Image Button


i have a gridview and i want to perform edit and delete with an image button

but unable to figure out the events and how i m gonna make my grid into edit mode ??

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                <asp:TemplateField HeaderText="S.No">
                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'></asp:Label>
                <asp:TemplateField HeaderText="Edit">
                        <asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Middle" 
                            ImageUrl="~/image/ico_edit.gif" CommandName="Edit" 
                            onclick="ImageButton1_Click" />
                <asp:TemplateField HeaderText="Delete">

jpg files will not display in gridview on aspx page

I have an image object in a template of a gridview The datasource of the image object evaluates to the path of the jpg file. However, the aspx page displays a little red x instead of the picture. How do I get the image to display/Frank learning vs 2005

Editing Image in Gridview VB.net

Hi, i'm back again and would like to seek help and advises from you experts on how to deal with problem. I have a table that accepts news data like title, content, link and a single image to be uploaded and attached to the database (not on file server). Now i want this Image Column (varbinary datatype) to be edited in case. When I tried puting an html fileupload in editing mode using gridview, I am getting error from the Image Column conversion like Image type cannot be converted into string. I know there is this scenario of reading and assigning data in my table, and then changing some codebehind and at the same time binding it into the gridview.This is my Image Handler:<%@ WebHandler Language="VB" %>Imports SystemImports System.WebImports System.ConfigurationImports System.Data.SqlClientPublic Class Handler : Implements IHttpHandler        Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest        Dim con As New SqlConnection()        con.ConnectionString = ConfigurationManager.ConnectionStrings("automotiveConnectionString").ConnectionString                ' Create SQL Command           &n

display icon or colum for inserted file in infopath form

i have a list with infopath form and in this form i have insert file now i need naythin in the view say there is attached or insert file in this record like the icon for attachment or column display file name or his path ,somthink can i know in this record there is attachmentThanks for any help :) my blog is: http://www.waelk.com
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend