Solved

select a drop down.

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

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 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