Johny Bravo
asked on
Find item in dropdownlist
Hi Experts,
I am finding a value in dropdownlist and making it selected.
if (ddlCity.Items.FindByText( Authentica te(Request .QueryStri ng["City"] .ToString( ))) != null) ddlCity.Items.FindByText(A uthenticat e(Request. QueryStrin g["City"]. ToString() )).Selecte d = 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.
I am finding a value in dropdownlist and making it selected.
if (ddlCity.Items.FindByText(
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.
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;
ASKER
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?
AndyAinscow : I don't want to loop through dropdownlist.It will work but looking for better one.
QuinnDex : What is StrConv and VbStrConv?
converting to propper case, will turn florida into Florida
ASKER
Getting error for both StrConv and VbStrConv.
Is it a function written somewhere. As far as I know it isn't in framework.
Is it a function written somewhere. As far as I know it isn't in framework.
its part of the System.Globalization class
add a Imports System.Globalization
add a Imports System.Globalization
ASKER
Using C#.
using System.Globalization;
if (ddlCity.Items.FindByText( Authentica te(StrConv (Request.Q ueryString ["City"], VbStrConv.ProperCase).ToSt ring())) != 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
using System.Globalization;
if (ddlCity.Items.FindByText(
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
>>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 ?
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 ?
http://forums.asp.net/p/1238455/2256368.aspx