473,952 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Masking DataTextField Output For Display In a ListBox

NBB
I can't figure this one out. Here's the situation, should be pretty
for the pros in here.

I have a ListBox that is populated with the DataTextField and
DataValueField flags of the DataSet. Everything populates just fine
and works great.

The DataTextField displays text from a database column called Path,
which is the absolute URL of a file. What I would like it to display
is just the filename, essentially trimming off everything previous to
(and including) the last forward slash character of the URL. I've come
up with this:

Right(thepath, (Len(thepath) - (thepath.LastIn dexOf("/")+1)))

Where "thepath" is a string representing the absolute URL. It works
great when I manually define thepath as a string. But I don't have
any idea how to implement this on the the values coming out of the
database's Path column.

I've been playing with the OnDataBinding and OnPreRender events for 2
days, but, alas, can't get them to work with the output of the
DataTextField.

Could someone shed some light on the matter? I doesn't seem like it
should be that hard to use a replace function or something like my
masking technique on the output, but I'm stumped.

Thanks for any help you can provide!
By the way, that's no longer my email address, so don't send to it.
I'll have to update my Google profile later today.
Nov 18 '05 #1
1 3114
NBB
Just following up my previous post (below) in case anyone is looking
to do the same type of thing. I've finally figured it out and have it
working as follows.

After populating my listbox in the typical way, I created a new public
sub as follows:

=============== =============== =============== =======
Public Sub Mask(Sender As Object, E As EventArgs)
Dim li As ListItem
For Each li In MyListBox.Items
li.text = Right(li.Text, (Len(li.Text) -
(li.text.LastIn dexOf("/")+1)))
Next
End Sub
=============== =============== =============== =======
Then, I added the event to the asp:listbox as:

OnPreRender="Ma sk"

The result of all this turns the contents of the database field:
"http://localhost/mysite/directory1/directory2/myfile.mp3" into
"myfile.mp3 "

Much easier to fit in a 100px wide listbox. :-)

I got this idea from researching a totally different issue here in the
groups nonetheless.

De********@eart hlink.net (NBB) wrote in message news:<49******* *************** ****@posting.go ogle.com>...
I can't figure this one out. Here's the situation, should be pretty
for the pros in here.

I have a ListBox that is populated with the DataTextField and
DataValueField flags of the DataSet. Everything populates just fine
and works great.

The DataTextField displays text from a database column called Path,
which is the absolute URL of a file. What I would like it to display
is just the filename, essentially trimming off everything previous to
(and including) the last forward slash character of the URL. I've come
up with this:

Right(thepath, (Len(thepath) - (thepath.LastIn dexOf("/")+1)))

Where "thepath" is a string representing the absolute URL. It works
great when I manually define thepath as a string. But I don't have
any idea how to implement this on the the values coming out of the
database's Path column.

I've been playing with the OnDataBinding and OnPreRender events for 2
days, but, alas, can't get them to work with the output of the
DataTextField.

Could someone shed some light on the matter? I doesn't seem like it
should be that hard to use a replace function or something like my
masking technique on the output, but I'm stumped.

Thanks for any help you can provide!
By the way, that's no longer my email address, so don't send to it.
I'll have to update my Google profile later today.

Nov 18 '05 #2

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

Similar topics

1
2699
by: Jason Heine | last post by:
Hello, I am have a web service which I pull a dataTable and then fill a listBox with the information. On the ListBox1.DataTextField = "myColumn"; I need to attempt the following: DateTime myColumn = new DateTime;
18
3366
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information from the dataset and how can I do that? Also, I set the property of the listbox to selectionmode...
0
938
by: Mike | last post by:
Greetings all - I'm trying to determine if .NET will allow me to do this and I'm at wits end on it. I have a listbox (Call it ListBoxB) that accepts values from another listbox (Call it ListboxA), which is bound to my database. I can set up the DataTextField and DataValueField fine in my ListBoxA which is bound but wondered how I can accomplish this in an unbound scenario because ListBoxB will ultimately needed to be submitted with the form...
3
6567
by: tshad | last post by:
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
3
6310
by: Nathan Sokalski | last post by:
I have a ListBox control which I am using with databinding. However, the text that I want to be displayed is a combination of two fields (in this case, first and last names). What do I enter as the DataTextField property to combine these two fields? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
2
2198
by: musosdev | last post by:
Hi guys I have an asp:ListBox on my form, which I'm populating with a DataReader, using DataSource/DataBind. The problem is that the main field I want to use for DataTextField, "Company" in this case, is often blank. How can I get the DataBinding to go... "if Company is blank, use ContactName, else use Company"
4
4293
by: l7alabeh | last post by:
Hi, I am trying to take from a database 3 values, concatenate the first two of them and insert them in a ListBox (in the DataTextField) and the 3rd value in the DataValueField. The problem is that I am able only to add the first two values concatenated (using the DataReader) but the DataValueField is not taking any new value, it is taking the value of the text.
5
2864
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that is what the ListBox uses for its display. Correct?
11
4419
by: gnewsgroup | last post by:
In my web application, I would like to dynamically display the progress of a process, something like: Collecting user input ... Saving user profile ... Generating report in PDF ... Dispatching report to user email ... This is something like the installation progress display of DotNetNuke or the Oracle's web-based enterprise manager.
0
10187
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11616
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11385
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
10710
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9921
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...
0
6368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4973
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
4570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3568
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.