473,385 Members | 2,269 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.

Higlight dropdown list item

53
Hi,

I am having 2 dropdown lists 1st dropdownlist contains A-Z list.2nd dropdown list contains some names like akila,bindu,chinni,....zibra etc.
when i select name in 2nd dropdown list, the first letter of that name should be highlight in 1st dropdown.eg. i select chinni then "C" should be highlight in 1st dropdown. Please help me how to resolve this problem.


Thanks in advance
Pavani
Jan 30 '09 #1
4 2793
Frinavale
9,735 Expert Mod 8TB
If you want to solve this using ASP.NET, enable "AutoPostBack" for the second DropDownList and then implement a method that will handle that control's SelectedIndexChanged Event.

For example, you'd set AutoPostBack="True" in your second DropDownList:
Expand|Select|Wrap|Line Numbers
  1. <asp:DropDownList ID="mySecondDropDownList" runat="server" AutoPostBack="True"></asp:DropDownList>
And then in your VB.NET code (or C# code) implement a method that handles the SelectedIndexChanged Event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub mySecondDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mySecondDropDownList.SelectedIndexChanged
  2.     'In this method you want to check the what letter the
  3.     'mySecondDropDownList.SelectedItem.Text  starts with
  4.     'and then select the corresponding item in 
  5.     'the firstDropDownList
  6. End Sub
  7.  
-Frinny
Jan 30 '09 #2
pavanip
53
Thanks for your response I got solution for my problem using the following code
Expand|Select|Wrap|Line Numbers
  1. foreach (ListItem item in ddlcont.Items)
  2. {
  3.     if (item.Text.StartsWith(txtcont.Text, StringComparison.CurrentCultureIgnoreCase))
  4.     {
  5.         ddlcont.SelectedIndex = ddlcont.Items.IndexOf(item);
  6.      }
  7. }
Jan 31 '09 #3
Frinavale
9,735 Expert Mod 8TB
Does your code actually work for you?
Why are you looping through all of the items in your DropDownList?
Feb 2 '09 #4
shweta123
692 Expert 512MB
Hi,

You can try the following code in SelectedIndexChanged event of second dropdownbox.

Expand|Select|Wrap|Line Numbers
  1. protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
  2.     {
  3.        //Here get the first character of the string item selected
  4.  
  5.         string strchar = DropDownList2.SelectedItem.Text.Substring(0, 1).ToString();
  6.  
  7.         // Highlight the item in the other dropdown accordingly
  8.  
  9.         DropDownList1.SelectedItem.Text = strchar;
  10.  
  11.     }
Note : Please make Autopostback property = true for Dropdownlist2 in order to work the above specified code.
Feb 2 '09 #5

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

Similar topics

20
by: Dannyboyo | last post by:
I have what I hope is a simple request. I can't really code in javascript, but I am pretty good at cusomizing it with slight modifications. I code in ASP and HTML. I am trying to capture customer...
6
by: passion_to_be_free | last post by:
This is probably simple, but I can't seem to find it anywhere. I have have some values stored in javascript variables. I have a <select> dropdown list whose options correspond to these values. I...
6
by: San Smith | last post by:
I have a dropdown list box with list of item. When I read the data from database I want to display that value(one of the item in the drop down box) in the dropdown list box. How to do that in a...
5
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
3
by: Big Dave | last post by:
I know it's been asked a million times before, but I still can't seem to find an answer that works. I've got a dropdown list in the footer template of a datagrid. The dropdown list databinds,...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
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: 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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.