Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to select dropdown  item and how to display field in dropdown

Posted on 2013-10-28
1
Medium Priority
?
372 Views
Last Modified: 2013-11-04
Hi,

Scenario 1:
for example I have one dropdown.Dropdown contains 4 items.I want to select 1 item in the dropdown.
Question:How to select dropdown item in C#?(is it dropdown1.selected value or selected item.text?)

Scenario 2:

I want to display some text(coming from database) in to dropdown.for example

( string test="Test1"

dropdown1.Text=test;  Is it correct?)

Can u plese help me regading above two scenarios?
0
Comment
Question by:mannevenu26
[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 8

Accepted Solution

by:
johny_bravo1 earned 2000 total points
ID: 39608628
How you bind your dropdowns?

dropdown1.DataSource = ds; (ds is DataSet object);
dropdown1.DataTextField = "ItemName"; (Text you want to display)
dropdown1.DataValueField = "ItemId"; (Id )
dropdown1.DataBind();

Now if you do,
dropdown1.SelectedItem.Text you will get the selected text from user.
dropdown1.SelectedItem.Value will give you the Id of the selected text.

Secenario 2:
dropdown1.Items.Add("Your string");
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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