后台绑定:
DataTable dt = RateStorage.GetDataTable(2);
foreach (System.Data.DataRow dr in dt.Rows)
{
ListItem li = new ListItem();
li.Value = dr["ChargeAmount"].ToString();
li.Text = (dr["Days"].ToString().TrimEnd()).PadRight(10, '\u00A0') + dr["ChargeAmount"].ToString();
if (dr["Days"].ToString() == "1")
{
li.Selected = true;
}
lbRate.Items.Add(li);
}
前台:
<asp:ListBox runat="server" ID="lbRate" Width="200px" Height="350px" SelectionMode="Single"></asp:ListBox>
在ie、firefox下测试通过
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2011/11/16/2251891.html,如需转载请自行联系原作者