How to pass Listbox1 value to Listbox2

Partial Class _Default
Inherits System.Web.UI.Page


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox2.Items.Add(ListBox1.SelectedItem.Text)
'if u want remove this item
ListBox1.Items.Remove(ListBox1.SelectedItem.Text)

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Add(ListBox2.SelectedItem.Text)
'if u want remove this item
ListBox2.Items.Remove(ListBox2.SelectedItem.Text)

End Sub
End Class


Partial Class _Default
Inherits System.Web.UI.Page


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox2.Items.Add(ListBox1.SelectedItem.Text)
'if u want remove this item
ListBox1.Items.Remove(ListBox1.SelectedItem.Text)

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Add(ListBox2.SelectedItem.Text)
'if u want remove this item
ListBox2.Items.Remove(ListBox2.SelectedItem.Text)

End Sub
End Class


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True">
<asp:ListItem>Ajith</asp:ListItem>
<asp:ListItem>Kumar</asp:ListItem>
<asp:ListItem>Kamal</asp:ListItem>
<asp:ListItem>Rajini</asp:ListItem>
</asp:ListBox>
<asp:ListBox ID="ListBox2" runat="server" AutoPostBack="True"></asp:ListBox>
<asp:Button ID="Button1" runat="server" Text="MoveToList2" />
<asp:Button ID="Button2" runat="server" Text="MoveToList1" /></div>
</form>
</body>
</html>

No comments:

Post a Comment

Plz Share your comments...