下拉列表中列的对齐方式

时间:2013-02-13 20:05:05

标签: c# asp.net

我使用下面的代码在下拉列表中显示和对齐列但是我的列没有对齐,在代码中我找到了获取第一列空间的最大长度,但我不知道它不起作用?

Drop Down list Alignment

protected void ddlProjectDocument_Load(object sender, EventArgs e)
{
    var query = from p in _DataContext.tblDocuments
                orderby p.DocumentNo
                select p;
    int maxs = 0;
    foreach (tblDocument v in query)
    {
        if (v.DocumentNo.Length > maxs)
            maxs = v.DocumentNo.Length;
    }

    foreach (tblDocument vv in query)
    {
        string doctitle = vv.DocumentNo;
        for (int i = vv.DocumentNo.Length; i < maxs + 2; i++)
        {
             doctitle += "&nbsp;";
        }
        doctitle += "&nbsp;|&nbsp;";
        doctitle += vv.TITLE;
        // Use HtmlDecode to correctly show the spaces
        doctitle = HttpUtility.HtmlDecode(doctitle);
        ddlProjectDocument.Items.Add(new ListItem(doctitle, vv.DocId.ToString()));
    }
}

0 个答案:

没有答案