Click here to Skip to main content
15,885,032 members
Articles / Web Development / HTML

GridViewImages from DB in ASP.NET using C#

Rate me:
Please Sign up or sign in to vote.
4.80/5 (12 votes)
26 Jun 2009CPOL4 min read 82K   2.5K   45  
GridViewImages from DB in ASP.NET using C#
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
            left: 109px; position: absolute; top: 159px" Text="Save Image" />
        <asp:FileUpload ID="FileUpload1" runat="server" Style="z-index: 101; left: 2px; position: absolute;
            top: 97px" />
            
            
        <asp:GridView ID="GridView1" runat="server" AllowSorting="true" DataKeyNames="Img_Id" Style="z-index: 102; left: 403px; position: absolute;
            top: 52px" AutoGenerateColumns="false">
            <Columns>
            <asp:BoundField DataField="Img_Id"  />
            <asp:TemplateField> 
 <ItemTemplate> 
    <asp:Image ID="Image1" runat="server" ImageUrl='<%#    "Handler.ashx?id=" + Eval("Img_Id")  %>' /> 
 </ItemTemplate> 
</asp:TemplateField></Columns>
        </asp:GridView>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" Style="z-index: 104;
            left: 241px; position: absolute; top: 261px">ShowImages</asp:LinkButton>
    
    </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer Pasca Software Solutions
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions