473,387 Members | 1,516 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,387 software developers and data experts.

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.LastIndexOf("/")+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 3088
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.LastIndexOf("/")+1)))
Next
End Sub
================================================== ==
Then, I added the event to the asp:listbox as:

OnPreRender="Mask"

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********@earthlink.net (NBB) wrote in message news:<49**************************@posting.google. 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.LastIndexOf("/")+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
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...
18
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...
0
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...
3
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
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...
2
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...
4
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...
5
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...
11
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.