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

how to get index of a text in dropdownlist?

nirmalsingh
218 100+
hai all, i am using asp.net(c#)
in a dropdown list i am having the values like
a
b
c
d

now i want to get the index of 'c'.
how to get it?
thanx in advance
Apr 15 '08 #1
5 13290
dip_developer
648 Expert 512MB
hai all, i am using asp.net(c#)
in a dropdown list i am having the values like
a
b
c
d

now i want to get the index of 'c'.
how to get it?
thanx in advance
Dim index as Integer=dropdownlist1.SelectedIndex....
and if you know the Item name then
dropdownlist1.Items.IndexOf("Item-Name")

...as simple as that....what problem..???
Apr 15 '08 #2
balame2004
142 100+
hai all, i am using asp.net(c#)
in a dropdown list i am having the values like
a
b
c
d

now i want to get the index of 'c'.
how to get it?
thanx in advance

Hi,

Try this:
dropdownList.Items.IndexOf("c");


Cheers,
Balaji U
Apr 15 '08 #3
kunal pawar
297 100+
this will you

create list item of same string u have to search and pass list item to IndexOf function
like
Dim lst = New ListItem("C")
dropdown.Items.IndexOf(lst)
Apr 15 '08 #4
Curtis Rutland
3,256 Expert 2GB
Just so you know, kunal pawar and dip_developer gave you the VB code.
balame2004's is the C# code you need.
Apr 15 '08 #5
nirmalsingh
218 100+
thank you all, it is working.
Apr 17 '08 #6

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

Similar topics

3
by: Earl Teigrob | last post by:
I want to write a function where I pass in a reference to a dropdownlist and a "match value" and have it returns the index of the dropdownlist item that matchs (or -1 if there is no match) ...
4
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx...
3
by: Dica | last post by:
if i manually populate a dropDownList, post the page, and then fetch the selected index, i'm able to get values other than 0. however, when i bound my dropDownList to a dataReader object, even...
2
by: Nathan Sokalski | last post by:
I have a DropDownList that is returning the value from index 0 regardless of which item is selected. The code that I am using to test which index it is returning is: Label1.Text =...
0
by: shamila | last post by:
I have an editable datagrid one of itz column is a dropdownlist <asp:TemplateColumn> <ItemTemplate> <asp:Label ID=lblAreaWebsiteID Runat=server text='<%#...
0
by: shamila.thakur | last post by:
I have an editable datagrid one of itz column is a dropdownlist <asp:TemplateColumn> <ItemTemplate> <asp:Label ID=lblAreaWebsiteID Runat=server text='<%#...
0
by: BigAde | last post by:
I'm having problems with the DDL in the datalist below when adding an item. The list binds properly and lists the correct values (up to about 350). The code successfully finds a ddl and...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
9
by: igotyourdotnet | last post by:
In my web app i have a drop down on my pages. I pass the selected item in the drop down from page to page. The issue is when I go back to page one I see the data in there twice. How can I have the...
2
by: rocksoft | last post by:
Hi I am working in asp.net with C# web application, I have used visual studio 2003, i have used dropdownlist in my application to populate the data from mysql database, i have got problem while...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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.