|
-
Dec 10th, 2002, 12:09 PM
#1
Thread Starter
Addicted Member
and into a blank listbox...?
Hi there...
I need to produce a facility to add items into a blank listbox from a full list box, and then produce reports based on the ones i have added into the blank one.
it will be a web application using aspx and aspx.vb files
i have creatde a blank web form and have added two list boxes and a button to it, where do i goes from here...?
please help, or show me a link to the code i need,
thanks
tom
-
Dec 13th, 2002, 02:38 PM
#2
Member
Just make sure you have .EnableViewState set to true for both of your listboxes, then all you have to do is something like this in a button for transferring one item to the other listbox
VB Code:
ListBoxNew.Items.Add(ListBoxMain.Items(ListBoxMain.SelectedIndex))
Enabling the ViewState, will make it so the new listbox retains its list on each postback
-
Dec 16th, 2002, 04:34 AM
#3
Thread Starter
Addicted Member
have tried that... am getting this error?
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
my code:
PHP Code:
Public Class TestLists
Inherits System.Web.UI.Page
Protected WithEvents ListBoxMain As System.Web.UI.WebControls.ListBox
Protected WithEvents Button As System.Web.UI.WebControls.Button
Protected WithEvents ListBoxNew As System.Web.UI.WebControls.ListBox
Protected WithEvents TagList As ReportClient.TagList
Dim Comp As Component1 = New Component1()
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TagList = New ReportClient.TagList()
CType(Me.TagList, System.ComponentModel.ISupportInitialize).BeginInit()
'
'TagList
'
Me.TagList.DataSetName = "TagList"
Me.TagList.Locale = New System.Globalization.CultureInfo("en-GB")
Me.TagList.Namespace = "http://www.tempuri.org/TagList.xsd"
CType(Me.TagList, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBoxMain.EnableViewState = True
ListBoxNew.EnableViewState = True
Comp.TagList.Fill(TagList)
ListBoxMain.DataBind()
End Sub
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
ListBoxNew.Items.Add(ListBoxMain.Items(ListBoxMain.SelectedIndex))
End Sub
End Class
-
Dec 16th, 2002, 08:43 AM
#4
Member
make sure your Page_Load code is inside a "If Not IsPostBack Then" statement to make sure it only executes the first time
-
Dec 16th, 2002, 09:37 AM
#5
Thread Starter
Addicted Member
ok, that works now, how do i insert an item into listboxnew when the user double clicks an item in listboxmain??
i also want to produce a report that shows all item from that listbox, do i have to write the data into a dataset and get the data that way?
Last edited by tmashley; Dec 16th, 2002 at 10:47 AM.
-
Dec 16th, 2002, 12:10 PM
#6
Member
double clicking is something that happens client side and has nothing to do with asp.net...you'd have to write up some javascript to do that.
-
Dec 17th, 2002, 04:38 AM
#7
Thread Starter
Addicted Member
any examples you know of?also what about the reporting?
Last edited by tmashley; Dec 17th, 2002 at 05:55 AM.
-
Dec 17th, 2002, 08:49 AM
#8
Member
I do my best to stay away from client-scripting 
As for the "reporting", just loop through the items collection in the new listbox and you'll have access to all the items to do with whatever you want
-
Dec 17th, 2002, 08:54 AM
#9
Thread Starter
Addicted Member
ok, that sounds good, i am new to this, how shall i go about this example code please... 
thanks
-
Dec 17th, 2002, 09:04 AM
#10
Member
you can use a for or a for each statement
VB Code:
Dim i As Int16
For i = 0 To ListBoxNew.Items.Count - 1
Response.Write("Item " & i & ListBoxNew.Items(i).Text & "<br>")
Next
something like that should work
-
Dec 17th, 2002, 09:08 AM
#11
Thread Starter
Addicted Member
i will need to retreive data from another sql table getting all the data related to each item of the list, will i have to perform "select" statements for each item, if so how?
i want to get all the values that are in the listbox and perform this action on each...
PHP Code:
rpTestReport.RecordSelectionFormula = "{tblTable.itmItem} = " & "'" & ListBoxItemN & "'"
is this possible??
Last edited by tmashley; Dec 18th, 2002 at 04:36 AM.
-
Jan 6th, 2003, 06:38 AM
#12
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|