在Page_Load()的表格中显示图片不起作用 [英] Showing pictures in tabel on Page_Load() do not work
本文介绍了在Page_Load()的表格中显示图片不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在使用Page_Load()方法在表中动态显示图片时遇到问题,这些图片未显示在表格单元格中,我也不知道为什么.
也许有人可以帮助我?
Hi all,
I have a problem to show pictures dynamic in a table in the Page_Load() method, the pictures are not shown in the table cells and I don''t know why.
Perhaps someone could help me?
String[] pic_ending = new String[] { ".gif", ".png", ".jpg" };
int rows = quantity/3;
if ((quantity % 3) != 0) rows++;
int col = 3;
int number = 0;
for (int r = 0; r < rows; r++)
{
TableRow myRow = new TableRow();
for (int c = 0; c < col; c++)
{
if (number == quantity) break;
String picture = "";
String[] allFiles = System.IO.Directory.GetFiles(name);
foreach (String s in allFiles)
{
foreach (string p in pic_ending)
{
if (s.Contains(p)) picture = s;
break;
}
}
picture = picture.Replace("C:\\inetpub\\" ,"~/");
picture = picture.Replace("\\", "/");
TableCell myCell = new TableCell();
myCell.Width = System.Web.UI.WebControls.Unit.Percentage(33);
myCell.HorizontalAlign = HorizontalAlign.Center;
myCell.Controls.Add(new LiteralControl("<asp:Image ID=\"Image" + number + "\" runat=\"server\" src=\"" + picture +"\"" + "/></br>" + distingtDir(name)));
myRow.Cells.Add(myCell);
number++;
}
UpperTable.Rows.Add(myRow);
}
推荐答案
UpperTable在哪里定义?是在标记中吗?如果不是,是否将其添加到控件集合?
Where is UpperTable defined? Is it in the markup? If not, is it added to the controls collection?
这篇关于在Page_Load()的表格中显示图片不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文