Solved

select a drop down.

Posted on 2004-08-17
1
218 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
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now