本演示是让你知道如何多个值绑定至ListBox显示为选中。ListBox在default情况之下,SelectionMode为Single,因此为了多选,而需要设置此属性为Multiple。在实现之前,可以先看到Insus.NET所实现最终效果,gif动画,无声音:

 ListBox 绑定多个选项为选中

 

 .aspx:

 <asp:TextBox ID="TextBox1" runat="server" Width="300"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Binding" OnClick="Button1_Click" />
        <br />
        <br />
        <asp:ListBox ID="ListBox1" runat="server" Height="100" SelectionMode="Multiple" ></asp:ListBox>

 

.aspx.cs中,首先是为ListBox准备数据,然后对ListBox控件进行数据绑定:

return site;
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2021-08-20
  • 2021-11-16
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案