使用列表<string> </string>中的数据填充2列表

时间:2015-01-11 19:05:34

标签: c# html asp.net list

我对填充2x *表的一段代码有疑问。当代码运行时,表被创建并显示。这应该是这样的。问题是该表位于页面底部。在我看到它之前,我必须滚动好5秒钟。

这是表格创建/人口:

string[] myDir = Directory.GetDirectories(path);

        List<HyperLink> hlist = new List<HyperLink>();

        foreach (string dir in myDir)
        {

            DirectoryInfo info = new DirectoryInfo(dir);
            string currentDirectoryName = info.Name;

            HyperLink hl = new HyperLink();
            hl.NavigateUrl = dir.ToString(); 
            hl.Text = currentDirectoryName.ToString();
            hlist.Add(hl);

            for (int i = 0; i < hlist.Count; i += 2)
            {
                TableRow row = new TableRow(); // Create the new rows
                Table1.Rows.Add(row);
                for (int j = i; j < Math.Min(i + 2, hlist.Count); j++)
                {
                    TableCell cell = new TableCell();
                    cell.CssClass = "RefItems";
                    cell.Controls.Add(hlist[j]);
                    row.Controls.Add(cell);
                }
            }

        }

关于为什么桌子到目前为止在屏幕上的任何想法?我认为这是显而易见的,因为我过去曾使用过这段代码并且工作正常。该表的HTML如下:

<asp:Panel ID="Panel1" runat="server">
                <asp:Table ID="Table1" runat="server"></asp:Table>
            </asp:Panel>

0 个答案:

没有答案
相关问题