Solved

select a drop down.

Posted on 2004-08-17
1
234 Views
Last Modified: 2012-05-05
I am retrieving data from a table and want have the value that I want as the selected value for a drop down. How do I loop through the drop down and make the value dtUserExist.Rows[0]["gender"].ToString() match what is in the options of the dropdown and then make it the selected index?
The name of the dropdown is called "Gender". Please advise?
0
Comment
Question by:solraccheffy
[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
1 Comment
 
LVL 9

Accepted Solution

by:
s_sansanwal earned 75 total points
ID: 11826862
try this
                  string data = dtUserExist.Rows[0]["gender"].ToString();
                  data = data.ToLower();
                  for(int index = 0; index < this.Gender.Items.Count; index++)
                  {
                        string item = this.Gender.Items[index].ToString();
                        if(item.ToLower() == data)
                        {
                              this.Gender.SelectedIndex = index;
                              break;
                        }
                  }


Cheers,
S Sansanwal
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 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