在运行时显示图像 [英] display images at run time
本文介绍了在运行时显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个asp.net Web应用程序.我在数据库中保存了9个项目,其中两个是图像..
我存储了图像的路径..现在在运行时,我已将所有数据保存在动态创建的html中
面板中的表格,但不是直接显示图像,而是图像的路径即将来临..我将如何显示图像..
我的编码是这个...
hi i am making an asp.net web application.. i saved 9 items in databse in which two of is image ..
i stored the path of the image.. now at run time i have taken all the data in dynamically created html
table in the panel but instead of image directly the path of the image is coming.. how will i display the image ..
my coding is this...
public partial class viewsearch : System.Web.UI.Page
{
OleDbConnection conn = new OleDbConnection();
protected void Page_Load(object sender, EventArgs e)
{
string cstring;
cstring = "provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("~/") + "db1.mdb";
conn.ConnectionString = cstring;
conn.Open();
string sb = Session["view"].ToString();
OleDbCommand cmd1 = conn.CreateCommand();
cmd1.CommandText = "select * from itemsale where itemsubcat=" + "''" + sb + "''";
OleDbDataReader dr1;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HtmlTable tbl = new HtmlTable();
tbl.Align = "center";
for(int i=0;i<=8;i++)
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell TDlbl = new HtmlTableCell();
Label lbl = new Label();
//lbl.CssClass = "FontClass";
lbl.Text = dr1.GetString(i);
lbl.Font.Bold = true;
lbl.Font.Size = 12;
TDlbl.Controls.Add(lbl);
tr.Cells.Add(TDlbl);
tbl.Rows.Add(tr);
Panel1.Controls.Add(tbl);
}
}
}
}
推荐答案
您需要创建一个Image
控件来包含图像;您不能使用标签.
You need to create an Image
control to contain the image; you can''t use a label.
这篇关于在运行时显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文