473,809 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listbox datavaluefield and datatextfield

How do I get to the datatextfield of listbox?

I can get the the datavaluefield using the selectedvalue. I want to get the
text portion of the listbox that the user selected.

Thanks,

Tom
Nov 19 '05 #1
3 6557
Hi,

In a list box the user can select single or multiple values. Below is the
code given for reading the multiple text values of the listbox in a string
seperated by commas.

Dim lCtr
Dim strText as String

If listBox.Items.C ount > 0 Then
For lCtr = 1 To lstBox.Items.Co unt
If istBox.Items(lC tr - 1).Selected = True Then
strText = lstBox.Items(lC tr - 1).Value
' Can have some code to append commas.......
End If
Next
End If

strText would be a string consistes od comma. You may also use the String
Builder class, if you want to optimise the string.

Please let me know if this is what you were looking for.....

Thanks and Regards,

Piyush
"tshad" wrote:
How do I get to the datatextfield of listbox?

I can get the the datavaluefield using the selectedvalue. I want to get the
text portion of the listbox that the user selected.

Thanks,

Tom

Nov 19 '05 #2
Tom try using :-
" ddlNamesList.Se lectedItem.Text "
e.g ddlNamesList being ur listBox
Patrick
"tshad" wrote:
How do I get to the datatextfield of listbox?

I can get the the datavaluefield using the selectedvalue. I want to get the
text portion of the listbox that the user selected.

Thanks,

Tom

Nov 19 '05 #3
"tshad" <tf*@dslextreme .com> wrote in message
news:uA******** *****@TK2MSFTNG P12.phx.gbl...
How do I get to the datatextfield of listbox?

I can get the the datavaluefield using the selectedvalue. I want to get the text portion of the listbox that the user selected.
Figured it out.

listbox.Selecte dItem.text

It is interested that for the value you can use either:

listbox.Selecte dValue or listbox.Selecte dItem.Value

I'm surprised that there isn't a listbox.Selecte dText also (to be
consistant).

Tom
Thanks,

Tom

Nov 19 '05 #4

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

Similar topics

3
1316
by: Paul W | last post by:
I am populating listbox with a datreader. DateReader sqlcommand is dynamic, based on several user selections Listbox DataValueField is set to the tables primary key Listbox DataTextField is multiple fields concatentated from SQL statement For example SELECT + ' ' + AS showText... Listbox would show the following Joe Smith... Mary Smith ... John Doe....
1
4017
by: Ray Valenti | last post by:
I have a ASP listbox that I am trying to populate with two fields, one for display (Category) and one to store (ID) as the selected item. I can successfully populate and view the list. How ever after specifying the field to hold the selected value with the Databindings property, the error below show up. VS changes the DataSource from DSMain1 to the expression: DataBinder.Eval(dsMain1, "Tables.DefaultView..fkeyCategory") Can I bind...
4
2465
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item, what do I need to do in order to return the "option value" of the control? Moe !--- returned value of the control
3
4793
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default item? I have tried the following: lstStates.Items.Insert(0, new ListItem("By State","0"))
5
3538
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all selected items of that listbox and display it. can anyone help? Thanks
0
1261
by: Gerald | last post by:
Hi, Is it possible to do some action on the value that will be the DataValueField of a listbox? I have a listbox with a list of item. But I would like to encode the value ID that the client will see in the html. There is no way to do that on the database, it has to be done on the .net side.
8
2358
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the event. I do have EnableViewState = True for the listbox. I'm imagining (wanting) to populate the listbox named: lstNames by using the DataValueField from lstDepartments. It's quite apparent though that the event is not triggering as I can misname...
6
1561
by: Sparky Arbuckle | last post by:
The code below works to an extent. The problem with it is that no matter which item is selected, the first one in the list is always the item that gets added/removed. How can I alleviate this problem? I have tried If Not Page.IsPostBack and still nothing. Private Sub btnCol1ToCol2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCol1ToCol2.Click Dim s As String = lbColumn1.SelectedItem.Text()...
4
4851
by: Marcos Beccar Varela | GamaCom Argentina | last post by:
Hello Everyone. I need to use a gridview, that when I use the Update command one of the colums, instead of showing a textbox where the user can write, I need a combobox (listobx), where there are 3 options. EG OF GRIDVIEW: USUER AGE carlosg old rominat young gonzalor normal florenciat young
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7661
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.