Sparky,
A simple test shows that your code should be working. And that the problem
has to be that databinding is recurring somewhere.
Here's what I tested with.
WebForm Code:
<form id="Form1" method="post" runat="server">
<asp:ListBox id="ListBox1" runat="server"> </asp:ListBox>
<asp:ListBox id="ListBox2" runat="server"> </asp:ListBox>
<asp:Button id="Button2" runat="server" Text="Button"></asp:Button>
</form>
Code Behind:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
'---First page load only
ListBox1.Items. Add(New ListItem("1"))
ListBox1.Items. Add(New ListItem("2"))
ListBox1.Items. Add(New ListItem("3"))
End If
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
ListBox2.Items. Add(ListBox1.Se lectedItem.Text )
ListBox1.Items. Remove(ListBox1 .SelectedItem.T ext)
End Sub
Keeping the task simple like this the code works. The only thing that could
be creating the problem you are describing is if the list box is being
re-bound. Based on the code you sent me you should change your populate list
box line to:
Function PopulateListBox ()
If Not IsPostBack Then
Dim strDLNumber As String = ddlDrawingList. SelectedItem.Te xt()
Dim objConn As New
OleDb.OleDbConn ection(Configur ationSettings.A ppSettings("str Connection"))
Dim strSQL As String = "SELECT tblDrawings.Dra wingNumber,
tblDrawings.ID FROM tblDrawingList INNER JOIN tblDrawings ON
tblDrawingList. ID = tblDrawings.ID WHERE (DLNumber = '" & strDLNumber &
"');"
Dim ds As New DataSet
Dim objCommand As New OleDb.OleDbComm and(strSQL, objConn)
Dim myCommand As New OleDb.OleDbData Adapter(strSQL, objConn)
myCommand.Fill( ds, "DataTable" )
lbColumn1.DataS ource = ds.Tables("Data Table")
lbColumn1.DataT extField = "DrawingNum ber"
lbColumn1.DataV alueField = "ID"
lbColumn1.DataB ind()
End If
End Function
Of course there may be a better place in your code to put the If Not
IsPostBack, but this should work for testing...
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Sparky Arbuckle" <tw*@secureroot .com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Here you go Justin:
This is the sub that handles the "Delete Drawings" button. It simply
hides / shows panels and populates the listbox.
Private Sub hlbtnDeleteDraw ings_Click(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles hlbtnDeleteDraw ings.Click
If Page.IsPostBack Then
PanelDeleteDraw ings.Visible = True
PanelAddDrawing s.Visible = False
PanelOptions.Vi sible = True
lblDrawingList. Text = "Delete drawings from: <b>" &
ddlDrawingList. SelectedItem.Te xt() & "</b>"
End If
PopulateListBox ()
End Sub
_____________
This is the function that populates the listbox with data.
Function PopulateListBox ()
Dim strDLNumber As String = ddlDrawingList. SelectedItem.Te xt()
Dim objConn As New
OleDb.OleDbConn ection(Configur ationSettings.A ppSettings("str Connection"))
Dim strSQL As String = "SELECT tblDrawings.Dra wingNumber,
tblDrawings.ID FROM tblDrawingList INNER JOIN tblDrawings ON
tblDrawingList. ID = tblDrawings.ID WHERE (DLNumber = '" & strDLNumber &
"');"
Dim ds As New DataSet
Dim objCommand As New OleDb.OleDbComm and(strSQL, objConn)
Dim myCommand As New OleDb.OleDbData Adapter(strSQL, objConn)
myCommand.Fill( ds, "DataTable" )
lbColumn1.DataS ource = ds.Tables("Data Table")
lbColumn1.DataT extField = "DrawingNum ber"
lbColumn1.DataV alueField = "ID"
lbColumn1.DataB ind()
End Function
_______________ ____________
This is the sub for the button to transfer Items from Column1 to
Column2:
Private Sub btnCol1ToCol2_C lick(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnCol1ToCol2.C lick
Dim s As String = lbColumn1.Selec tedItem.Text
lbColumn2.Items .Add(s)
lbColumn1.Items .Remove(s)
End Sub