如何从GridView中的SQL表显示图像? [英] how to display image from sql table in gridview?
本文介绍了如何从GridView中的SQL表显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将图像从sql表显示到gridview,但是它不显示此代码来将gridview与sql表记录绑定..
hi i tried to display image from sql table to gridview but its not displaying this s my code to bind gridview with sql table records..
protected void Page_Load(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("Select * from tblImage",con);
try
{
cmd.Connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
gvwExample.DataSource = reader;
gvwExample.DataBind();
cmd.Connection.Close();
cmd.Connection.Dispose();
}
catch (Exception ex)
{
lblStatus.Text = ex.Message;
}
}
这是设计代码
and this is the design code
<pre><asp:GridView ID="gvwExample" runat="server" AutoGenerateColumns="false">
<columns>
<asp:BoundField DataField="iName" HeaderText="Name" />
<asp:BoundField DataField="iAddress" HeaderText="Address" />
<asp:TemplateField HeaderText="Photo">
<ItemTemplate>
<asp:Image ID="Image1" ImageUrl=''<%#(Eval("iImage"))%>'' runat="server" Width="200" Height="200"/>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
请提出建议..谢谢..
please suggest..thanks and regards..
推荐答案
请尝试以下链接,有关CP的一些好的文章肯定会对您有所帮助:
面向初学者的简单指南,介绍了一种在ASP.NET网页内的GridView上显示从数据库获取的图像的方法:
在GridView中显示数据库中的图像 [^ ]
显示/存储和检索图像数据,从数据库到Gridview,也可以将鼠标悬停在以下位置: ^ ]
使用Microsoft .NET从SQL Server存储和检索图像 [ ^ ]
在SQL Server中存储或保存图像 [ ^ ]
将图像存储到数据库并检索到GridView [使用C#在SQL Server数据库中存储或保存图像 [^ ]
使用RIA服务在SQL Server中存储图像 [ ^ ]
在gridview中显示图像 [在GridView中从数据库Asp.Net显示图像 [ ^ ]
使用Asp.net C#从Sql Server数据库表在GridView中显示图像 [^ ]
ASP.NET的GridView示例:在GridView中显示图像 [使用asp.net从数据库中保存和检索图像 [ ^ ]
Please try following links, some good articles on CP will surely do some needful for you:
A simple guide for beginners, explaining one method of displaying images taken from a database on a GridView inside an ASP.NET web page:
Displaying Images from a Database in a GridView[^]
Display/Store and Retrieve Image Data from Database to Gridview, and also on mouse over: Display/Store and Retrieve Image Data from Database to Gridview, and also on Mouse Over[^]
Storing and Retrieving Images from SQL Server using Microsoft .NET[^]
Store or Save images in SQL Server[^]
Storing Images to Database and Retrieving to GridView[^]
Store or save images in SQL Server database using C#[^]
Storing images in SQL Server with RIA Services[^]
Display image in gridview[^]
Display Images In GridView From DataBase Asp.Net[^]
Display Images in GridView from Sql Server Database Table Using Asp.net C#[^]
GridView Examples for ASP.NET: Displaying Images in a GridView [^]
Save and retrieve images from database using asp.net[^]
<asp:Repeater ID="repview" runat="server" >
<ItemTemplate>
<td class="bdr_top para_cbox bdr_lft">
<%#Eval("name")%>
</td>
<td align="center" class="bdr_lft bdr_top para_cbox ">
<img src="<%#Eval("iImage")%>" alt="" border="0" height="50" width="50" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
这篇关于如何从GridView中的SQL表显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文