ASP.Net Databind in DropDownList - TechRepublic
General discussion
July 25, 2006 at 03:02 AM
bsmgopal1984

ASP.Net Databind in DropDownList

by bsmgopal1984 . Updated 19 years, 11 months ago

I tried to display the values from oracle table into a dropdownlist which is in asp.net.I used the below code to bind the data.When I debug,the page loads completely.But it doesn’t show anything in the dropdownlist.How can I get the Oracle table values in asp.net dropdownlist.
I used the below code:

private void Page_Load(object sender, System.EventArgs e)
{
InitializeComponent();
ConnStr=”Provider=msdaora;Data Source=inchnred;User Id=inchnset;Password=inchn;”;
Conn=new OleDbConnection(ConnStr);
Conn.Open();
DataAdpt=new OleDbDataAdapter(“SELECT * FROM TBLTEST”,Conn);
DataAdpt.SelectCommand.CommandType=CommandType.Text;
DataSet ds=new System.Data.DataSet(“TBLTEST”);
DataAdpt.Fill(ds,”tbltest”);
DropDownList1=new DropDownList();
DropDownList1.DataSource=ds.Tables[0];
DropDownList1.DataTextField=”Name”;
DropDownList1.DataValueField=”EMP”;
DropDownList1.DataBind();
}

*Table name is TBLTEST
*It has columns Name,EMP

This discussion is locked

All Comments