Use ashx to display the pictures read from the database in the DataGrid.

Source: Internet
Author: User
For the ashx suffix file, see the article about how to eliminate the image from being cached in ie and cannot be updated.
Read and save images from the database. Read and write images (c # asp. Net sqlserver) related articles

The following uses the ashx file to conveniently read images from the database and display them in the datagrid.

// ----------------------------------------- BindImage. aspx ----------------------------------------
<% @ Page language = "c #" Codebehind = "BindImage. aspx. cs" AutoEventWireup = "false" Inherits = "ShowImage. BindImg" %>
<HTML>
<HEAD>
<Title> BindImg </title>
</HEAD>
<Body>
<Form id = "Form1" method = "post" runat = "server">
<FONT face = "">
<Asp: DataGrid id = "MyDataGrid" runat = "server" AutoGenerateColumns = "False" Width = "632px">
<AlternatingItemStyle BackColor = "Beige"> </AlternatingItemStyle>
<HeaderStyle HorizontalAlign = "Center"> </HeaderStyle>
<Columns>
<Asp: TemplateColumn HeaderText = "Photo">
<ItemTemplate>
'>
</ItemTemplate>
</Asp: TemplateColumn>
<Asp: BoundColumn DataField = "LastName" HeaderText = "Last Name"> </asp: BoundColumn>
<Asp: BoundColumn DataField = "FirstName" HeaderText = "First Name"> </asp: BoundColumn>
<Asp: BoundColumn DataField = "title" HeaderText = "Title"> </asp: BoundColumn>
</Columns>
</Asp: DataGrid> </FONT>
</Form>
</Body>
</HTML>
// -------------------------------------- BindImage. aspx. cs ---------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.