C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Databinding »

Populating drop down list


Posted Date: 31 May 2009    Resource Type: Code Snippets    Category: Databinding
Author: ParvathiMember Level: Gold    
Rating: 1 out of 5Points: 5



To populate value in dropdownlist

sqldataadapter ada = new sqldataadapter("select * from tablename",conn);
Datatable dt = new Datatable();
ada.fill(dt);
dropdownlist1.datatextfield = dt[0].toString();
dropdownlist1.datavaluefield = dt[1].toString();
dropdownlist1.databind();




Responses

Author: ammiraju    01 Jun 2009Member Level: Silver   Points : 0
Hi,

Use DropDownList Datasource property.


Author: Ramya    01 Jun 2009Member Level: Silver   Points : 1
dropdownlist1.datatextfield = dt[0].toString() ;dropdownlist1.datavaluefield = dt[1].toString
dropdownlist1.datasource = dt;
();dropdownlist1.databind();



Author: Danasegarane.A    01 Jun 2009Member Level: Diamond   Points : 2
This is the Poor method binding.. I don't know who approved this....

It should be like


sqldataadapter ada = new sqldataadapter("select * from tablename",conn);
Datatable dt = new Datatable();
ada.fill(dt);
dropdownlist1.datasource = dt;
dropdownlist1.datatextfield = "Name";
dropdownlist1.datavaluefield = "ID";
dropdownlist1.databind();





Author: Anand    02 Jun 2009Member Level: Silver   Points : 1
hi,

Using the DDl DataSource property.

dropdownlist1.datatextfield = dt[0].toString() ;
dropdownlist1.datavaluefield = dt[1].toString();
dropdownlist1.datasource = dt;
dropdownlist1.databind();


Author: Abhay    02 Jun 2009Member Level: Diamond   Points : 1
sqldataadapter ada = new sqldataadapter("select * from tablename",conn);Datatable dt = new Datatable();
ada.fill(dt);
dropdownlist1.datasource = dt;
dropdownlist1.datatextfield = dt[0].toString();
dropdownlist1.datavaluefield = dt[1].toString();
dropdownlist1.databind();


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Populating dropdownlist  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ASP page with database handling
Previous Resource: Populating drop down list using arraylist
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use