0

我如何将这行代码转换为例如, <li>DE</li>

optionlist.Append("<option value=\"" +
                  DB.RSField(rs, "Name") +
                  "\" " +
                  CommonLogic.IIF(currentLocaleSetting == DB.RSField(rs, "Name"), " selected ", String.Empty) +
                  ">" +
                  DB.RSField(rs, "Description") +
                  "</option>");

我也试过这个:

optionlist.Append("<li>" + "a href=" + 
"/setlocale.aspx?returnURL=Default.aspx&localesetting=" + DB.RSField(rs, "Name") +
 "</a>" + CommonLogic.IIF(currentLocaleSetting == DB.RSField(rs, "Name"), "", String.Empty) + "" + DB.RSField(rs, "Description") + "</li>");

但这会产生以下错误:

a href=/setlocale.aspx?returnURL=Default.aspx&localesetting=de-DEDeutsch

4

1 回答 1

2

为了生成列表项,代码应如下所示:

optionlist.Append("<ul>");

//loop start here...
optionlist.AppendFormat("<li>{0}</li>", DB.RSField(rs, "Name"));
//loop ends here...

optionlist.Append("</ul>");

但是,这将“丢失”描述,因此也要添加它:

optionlist.Append("<ul>");

//loop start here...
optionlist.AppendFormat("<li>{0} <a href=\"/setlocale.aspx?returnURL=Default.aspx&localesetting={0}\">{1}</a></li>", DB.RSField(rs, "Name"), DB.RSField(rs, "Description"));
//loop ends here...

optionlist.Append("</ul>");

上面将显示每个名称旁边的描述。

于 2012-06-12T13:02:52.027 回答