Solved

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

Posted on 2013-10-28
1
367 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 500 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
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 this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

617 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