473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

asp.net:listbox accessing values

his is a hybrid problem i.e. the answer lies either in javascript or
vb.net so forgive me if this is the wrong group.

I have this javascript:

function moveItems(fromItem, toItem)
// Moves selected items from one ListBox to another.
{
var NoofItems = fromItem.options.length
for (i=0; i < NoofItems; i++)
{
if (fromItem.children[i].selected )
{
var anode = fromItem.children[i].cloneNode (true)
toItem.appendChild(anode)
fromItem.removeChild(fromItem. children[i])
NoofItems = fromItem.children.length
i--
}
}
}

which when called appears to move an item from 1 listbox to another.
However in vb.net when I run this code
If TeamDivisions.Items.Count > 0 Then
For intCount = 0 To TeamDivisions.Items.Count -
1
.WriteStartElement("TeamDivisi ons")
TeamDivisions.SelectedIndex = intCount
.WriteAttributeString("Divisio nId",
TeamDivisions.SelectedItem.Val ue)
.WriteEndElement()
Next
End If

the TeamDivisions.Items.Count returns 0 even when I know there are rows
in the control.

Any ideas why this control cannot be accessed in vb.net? In vb.net's
immediate window I can access the listbox from which the items are
removed to the above control using Items.Count, SelectedIndex,
SelectedItem.Value without a problem but the receiving list listbox
i.e. TeamDivisiones doesn't work at all.

Does the problem lie with my javascript?

Thanks for your help

Duncan

Nov 19 '05 #1
1 1457
Sorted it
I found I had to have a hidden input field and when the page is
submitted append the values in the listbox to the hidden field. In
my case this looked like "1,2,3". I then used vb.net to split the
values.
The reason for this is apparently the text and values in a listbox are
not posted back to the server.

Hope this helps

Duncan

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex Fimine | last post by:
Hi, I have a list box lstMy which is bound to a datatable dt. The SelectionMode in the listbox is set to MultiSimple. I want to run through the listbox and return all _values_ from the...
0
by: Jax | last post by:
I have a listbox. When the user selects an item i want to to take the text of the item and manipulate it. It wasn't working when autopostback was false, now it's true the event runs but i get an...
1
by: Robert Smit | last post by:
I have the following problem: If I run this code: dagCap1.berekenDagCapaciteit(ref lbOrderDag1); I get the error that I can't read the first row from the ListBox. ...
1
by: Melson | last post by:
Hi May I know what is the differences between vb.net listbox and listview. When should I use listbox or listview. Regards Melson
4
by: the_mikado | last post by:
Hi, If this has been answered before I am sorry, but I want to wordwrap the items in a listbox so I dont have to use the horizontal scroll bar. Is this possible? if so how can it be done? ...
1
by: Dessip | last post by:
Hey there, my question is, I have got 2 List Boxes, on a page, and listbox 1 generates list box 2 items, but both are generated from SQL, but its not worknig on auto post back: Code...
0
by: ruby anne | last post by:
how do i access a row in a datagrid when i use the mouse to select on the row so i can delete it from the sql database?and where do i store it so i can manipulate its values and put it in a textbox?...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
0
daJunkCollector
by: daJunkCollector | last post by:
Dear Community, I have thoroughly researched the subject of removing or modifying the border on an <asp:Listbox> control. Every nook and cranny I search leads to hopelessness. Could anyone shed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.