1<asp:MultiListBox ID="ListBox1" runat="server" Rows="10" Width="250px" Height="200px" DataTextField="UserName" DataValueField="UserID" SelectionMode="Multiple">
2 <FirstListBox><StyleSheet Width="100px" /></FirstListBox>
3 <SecondListBox><StyleSheet Width="100px" /></SecondListBox>
4 </asp:MultiListBox>
5
Submit
1protected void Page_Load(object sender, EventArgs e)
2 {
3 if (Page.IsPostBack)
4 return;
5 ListBox1.FirstListBox.DataSource = LoadData(1, 5);
6 ListBox1.SecondListBox.DataSource = LoadData(6, 10);
7 ListBox1.DataBind();
8}
9protected void Button1_Click(object sender, EventArgs e)
10 {
11 Response.Write("您SecondList选择的值为:<br/>");
12 foreach (ListItem item in this.ListBox1.SecondListBox.Items)
13 {
14 Response.Write(item.Text + ":" + item.Value + "<br/>");
15 }
16 Response.Write("您FirstList选择的值为:<br/>");
17 foreach (ListItem item in this.ListBox1.FirstListBox.Items)
18 {
19 Response.Write(item.Text + ":" + item.Value + "<br/>");
20 }
21 }
22 |