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 »

dropdown Filling with TextField and Value Field


Posted Date: 06 Oct 2008    Resource Type: Code Snippets    Category: Databinding
Author: raviMember Level: Gold    
Rating: 1 out of 5Points: 6



This code describes how to fill dropdown using dataset

Consider a Dropdownlist ddlTest, table tblEmp with

2 columns say eno,ename

private void FillDropdown()
{
Try
{

string strQry =" select eno, ename from tblEmp";

Dataset ds = new DataSet();
da = new SqlDataAdapter(strQry , m_objConn);
da.Fill(ds,"DATA_TABLE");
da.Dispose();
ddlTest.Items.clear();
ddlTest.DataValueField ="eno";
ddlTest.DataTextField ="ename";
ddlTest.DataSouce = ds.Tables["DATA_TABLE"];
ddlTest.DataBind()

}
catch(exception ex)
{
ex.Message.ToString();
}
}

<b>
using ddlTest.selectedItem.Text we can Get the selected ename
using ddlTest.SelectedItem.Value we can get the selected eno
</b>




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Dropdown filling  .  Dataset  .  

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: simple code to binding data with data control for beginners
Previous Resource: Paging of Data list
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use