Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Search an image for an image 3 30
PL SQL Developer 7 35
Help with exporting to excel 4 28
VB.NET 2008 - SQL Timeout 9 24
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

777 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