日期:2014-05-17  浏览次数:20624 次

asp.net Gridview显示多张图片,显示不出来,求助,急急急
下面的<img src="./imagebase/1.jpg" alt="" />就可以显示出来,而Gridview中的图片就显示不出来,将ima改为img也不行,希望各位帮帮忙

本人很菜,希望各位回答是能说说具体应该怎样写,错在哪里

HTML code

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
   
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" onpageindexchanging="GridView1_PageIndexChanging" 
            Width="624px">
            <PagerSettings FirstPageText="第一页" LastPageText="最后页" NextPageText="下一页" 
                Position="TopAndBottom" PreviousPageText="上一页" />
                <Columns>
                    <asp:TemplateField>
                    <ItemTemplate>
                        <ima alt="" src='〈%# DataBinder.Eval(Container, "DataItem.filePath", "{0}") %>'/>
                    </ItemTemplate>
                    </asp:TemplateField>
                </Columns>              
               
        </asp:GridView>
        <img src="./imagebase/1.jpg" alt="" />
</asp:Content>




C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Net;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("filePath");
        DataRow dr = dt.NewRow();
        dr["filePath"] = "./imagesbase/1.jpg";
        dt.Rows.Add(dr);
        this.GridView1.DataSource = dt;
        this.GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

    }
}



网页运行是查看源代码,是
HTML code

 <div>
    <table cellspacing="0" rules="all" border="1" id="MainContent_GridView1" style="width:624px;border-collapse:collapse;">
        <tr>
            <th scope="col">&nbsp;</th>
        </tr><tr>
            <td>
                        <ima alt="" src='〈%# DataBinder.Eval(Container, "DataItem.filePath", "{0}") %>'/>
                    </td>
        </tr>
    </table>
</div>
        <img src="./imagebase/1.jpg" alt="" />



点击这里的<ima alt="" src='〈%# DataBinder.Eval(Container, "DataItem.filePath", "{0}") %>'/>可以看到以下源代码

HTML code

<html>
    <head>
        <title>Bad Request</title>
        <style>
            body {font-family:"Verdana";font-w