DataTable dt = new DataTable(); string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\OnCall Tracker_2011.xls;Extended Properties='Excel 8.0;HDR=NO'"; using (OleDbConnection conn = new OleDbConnection(connString)) { conn.Open(); //Where [F1] = column one, [F2] = column two etc, etc. //OleDbCommand objCmdSelect = new OleDbCommand(sqlQuery, conn); //objCmdSelect.ExecuteNonQuery(); string sqlQuery = "select distinct [F1] AS [id] from [July -11$]"; OleDbDataAdapter adapter = new OleDbDataAdapter(sqlQuery, conn); adapter.Fill(dt); DropDownList1.DataSource = dt; DropDownList1.DataBind(); }
DropDownList1.DataSource = dt;
DropDownList1.DataTextField= dt.Columns[0].ToString(); DropDownList1.DataValueField = dt.Columns[0].ToString();
DropDownList1.DataTextField = "id"; DropDownList1.DataValueField = "id"; DropDownList1.DataSource = dt; DropDownList1.DataBind();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)