?
Solved

Find item in dropdownlist

Posted on 2013-11-16
11
Medium Priority
?
398 Views
Last Modified: 2013-11-16
Hi Experts,

I am finding a value in dropdownlist and making it selected.


if (ddlCity.Items.FindByText(Authenticate(Request.QueryString["City"].ToString())) != null)           ddlCity.Items.FindByText(Authenticate(Request.QueryString["City"].ToString())).Selected = true;



When the item present in dropdownlist is "Florida", and I am getting value as "Florida" this works fine, but when I receive "florida" then it won't find the text.

Can I ignore the case sensitivity.
0
Comment
Question by:johny_bravo1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39653007
This seems to do a case independent find:
http://forums.asp.net/p/1238455/2256368.aspx
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39653074
try this


if (ddlCity.Items.FindByText(Authenticate(StrConv(Request.QueryString["City"], VbStrConv.ProperCase).ToString())) != null)

ddlCity.Items.FindByText(Authenticate(StrConv(Request.QueryString["City"], VbStrConv.ProperCase).ToString())).Selected = true;

Open in new window

0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 39653100
Thanks for the reply.

AndyAinscow : I don't want to loop through dropdownlist.It will work but looking for better one.

QuinnDex :  What is StrConv and VbStrConv?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:QuinnDex
ID: 39653104
converting to propper case, will turn florida into Florida
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39653107
lots of ways to do it see below

http://support.microsoft.com/kb/312897
0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 39653108
Getting error for both StrConv and VbStrConv.

Is it a function written somewhere. As far as I know it isn't in framework.
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39653110
its part of the System.Globalization class

add a Imports System.Globalization
0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 39653122
Using C#.

using System.Globalization;

if (ddlCity.Items.FindByText(Authenticate(StrConv(Request.QueryString["City"], VbStrConv.ProperCase).ToString())) != null)

Error:

Error      5      The name 'VbStrConv' does not exist in the current context      
Error      4      The name 'StrConv' does not exist in the current context
0
 
LVL 9

Accepted Solution

by:
QuinnDex earned 2000 total points
ID: 39653126
different aproach for c# sorry



if (ddlCity.Items.FindByText(Authenticate(CultureInfo.CurrentCulture.TextInfo.ToTitleCase((Request.QueryString["City"]).ToString())) != null)

Open in new window

0
 
LVL 8

Author Closing Comment

by:johny_bravo1
ID: 39653128
Thanks
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39653203
>>AndyAinscow : I don't want to loop through dropdownlist.It will work but looking for better one.

You will probably find that is what is done, just in the background.  (Magic doesn't exist - it is all an illusion).

Just out of interest does the selected comment actually work if the list item is florida instead of Florida ?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question