我想将数据填充到选择控件中,如:
abc || 1
bcde || 2
ghife || 3
我的代码
ArrayList arr = new CMProduct().getList();
string str = "<option value='0'>" + strApp + "</option>";
if (arr != null)
{
foreach (MProductInfo info in arr)
{
string select = "";
string sName = "";
if (info.ID == id_select)
select = "selected";
//int length = 80;
int fLengthString = info.Name.Length;
int iPadRight = 0; iPadRight = 100 - fLengthString;
sName = info.Name.PadRight(iPadRight, '\u00a0');
str += "<option " + select + " value='" + info.ID + "'>" + sName + info.Code + "</option>";
}
}
return str;
Ressult:
abc || 1
bcde || 2
ghife || 3
那么如何解决呢?