C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




dropdown Filling with TextField and Value Field


Posted Date: 06 Oct 2008    Resource Type: Code Snippets    Category: Databinding

Posted By: ravi       Member Level: Gold
Rating:     Points: 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  
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   BizTalk Adaptors    Web Design

conference call definitions

Contact Us    Privacy Policy    Terms Of Use