| Author: nirmala 28 Jul 2008 | Member Level: Gold | Rating: Points: 6 |
haii, try for this code:
.aspx:
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1" SelectionMode="single" DataTextField="first_name" DataValueField="first_name"> </asp:ListBox> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:ListBox ID="ListBox2" runat="server"></asp:ListBox> <br /> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:...... %>" SelectCommand="SELECT [first_name], [last_name] FROM [login_inf]" ></asp:SqlDataSource> .cs:
protected void Button1_Click(object sender, EventArgs e) { if (ListBox1.Items.Count != 0) { for (int i = 0; i < ListBox1.Items.Count; i++) {
if (ListBox1.Items[i].Selected == true) { ListItem items = ListBox1.SelectedItem; if (items != null) { ListBox1.Items.Remove(items); ListBox2.ClearSelection(); ListBox2.Items.Add(items); } } } }
|