-
样板 <asp:ListBox ID="ListBox1" runat="server" Height="20px" Width="73px"> <asp:ListItem Selected="True" Value="1">第一项</asp:ListItem> <asp:ListItem Value="2">第二项</asp:ListItem> <asp:ListItem Value="3">第三项</asp:ListItem> <asp:ListItem Value="4">第四项</asp:ListItem> </asp:ListBox>
- 添加ListItem项
- 在页面上选编辑项----添加Item项 确定
- 在Listbox属性页面里 Item集合
- 编程方式
if (!IsPostBack) { ListBox1.Items.Add("第一项"); ListBox1.Items.Add("第二项"); ListBox1.Items.Add("第san项"); ListBox1.Items.Add(new ListItem("第四项", "4", true)); }
Item.Add(string Item); Item.Add(ListItem Item);//可控制text value enabled属性protected void Button1_Click(object sender, EventArgs e) { this.Label1.Text = this.ListBox1.SelectedValue+ "---"+ListBox1.SelectedItem.Text; }//
ListBox1.SelectedItem.Value 选中的value值 Item.Text显示的文本 ListBox1.SelectedIndex.ToString()从0开始,选中的为第几项
- 在页面上选编辑项----添加Item项 确定
ASP Web控件-----ListBox
最新推荐文章于 2022-03-29 16:07:59 发布