473,385 Members | 2,003 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,385 software developers and data experts.

Dropdownlist

14
Hi all.

I have a dropdownlist that has the usernames of people that I am getting from a sql table. However I must now only get the text after the / character in the username. Not sure on how to go aobut this. Could I possibly use SUBSTRING? Usernames are not all equal lengths.

Any help would be greatly appreciated
Thank you
Apr 11 '08 #1
6 1337
DrBunchman
979 Expert 512MB
Hi devlin,

Here's a little code snippet which will get all the text after a certain character (assumes you have a recordset object called rs):
Expand|Select|Wrap|Line Numbers
  1. Dim sUsername 
  2. Dim sCol = rs("ColumnName"), 
  3. If Instr(sCol, "/") > 0 Then
  4.      sUsername = Split(sCol , "/")(1)
  5. End If
  6.  
Do you know how the split function works? It creates an array from a string using a specified character as a delimiter. In this instance it splits the username from the database into two strings using the "/" as the dividing point and assigns the second item (which will be everything after the "/") to the variable sUsername.

Does this make sense? Let me know how you get on.

Dr B

PS you are using Classic ASP aren't you? If you're using .NET then let me know because the code will be slightly different.
Apr 11 '08 #2
devlin
14
Hi devlin,

Here's a little code snippet which will get all the text after a certain character (assumes you have a recordset object called rs):
Expand|Select|Wrap|Line Numbers
  1. Dim sUsername 
  2. Dim sCol = rs("ColumnName"), 
  3. If Instr(sCol, "/") > 0 Then
  4.      sUsername = Split(sCol , "/")(1)
  5. End If
  6.  
Do you know how the split function works? It creates an array from a string using a specified character as a delimiter. In this instance it splits the username from the database into two strings using the "/" as the dividing point and assigns the second item (which will be everything after the "/") to the variable sUsername.

Does this make sense? Let me know how you get on.

Dr B

PS you are using Classic ASP aren't you? If you're using .NET then let me know because the code will be slightly different.

Hi, Thank you for the quick reply.
I got it sorted out about 15 minutes before I saw your reply.
Now for the hectic stuff!
Thanks
Apr 11 '08 #3
DrBunchman
979 Expert 512MB
Good work! Glad you got it sorted by yourself.

Dr B
Apr 11 '08 #4
devlin
14
Good work! Glad you got it sorted by yourself.

Dr B
Just one little thing I have to add... If I need to display the usernames alphabetically in the ddl... How would i do that in my code? As i cant SORT BY in my stored procedure because It will return them in alphabetical order but I am Using SUBSTRING to leave out the text until the / in the string. and it will bring them back alphabetically before I use substring and will not show them correctly.

Any ideas or advice?

Thank you
Apr 11 '08 #5
devlin
14
Hopefully that made sense.....
Apr 11 '08 #6
DrBunchman
979 Expert 512MB
You could store the usernames in an array and then sort that. If you're using .NET this will be easy enough using the Sort method.

If you're using Classic ASP then the following link contains a useful sort script.

http://snippets.dzone.com/posts/show/3233

Hope this helps,

Dr B
Apr 11 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
2
by: Shiju Poyilil | last post by:
Hello, I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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.