<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="bookname" Height="504px"
Width="289px">
<Columns>
<asp:TemplateField HeaderText="image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# String.Format("~/path/to/image/" + Eval("image")) %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("image") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="bookname" HeaderText="bookname" ReadOnly="True"
SortExpression="bookname" />
<asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [image], [bookname], [price] FROM [books]">
</asp:SqlDataSource>
我的图像字段保存在(SQL server 2005)中...并通过文件上传按钮将图像插入数据库...现在我想在gridview中显示数据但不显示图像字段和gridview中显示的其他字段很好,因为其他字段是文本格式。