?
Solved

select a drop down.

Posted on 2004-08-17
1
Medium Priority
?
239 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 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 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