Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data bind problem

Status
Not open for further replies.

Yelellav

Programmer
Feb 7, 2002
12
US
Can some help me figure out why the code below will not populate a drop down box. Thanks

//build query string
string thisSQL = "select distinct column1 from table1";
thisSQL = thisSQL + "where 0 = 0 ";
string next;
for(int i = 0; i < divList.Count; i++)
{
if (i == 0)
next = "and ";
else
next = "or ";
div = divList.ToString().Remove(3, divList.ToString().Length - 3);
sec = divList.ToString().Remove(0, divList.ToString().Length - 2);
thisSQL = thisSQL + next +"(column2 = " + div + " and column3 = " + sec + ") ";
}

//instantiate db connection
databaseConnection dbConnection = new databaseConnection();
//instantiate sql command
OracleCommand sqlCommand = new OracleCommand();
//instantiate return dataset
DataSet ds = new DataSet();
//call function to open connection and set as connection
sqlCommand.Connection = dbConnection.openDB();
//set select command text
sqlCommand.CommandText = thisSQL;
//create data adapter
OracleDataAdapter domainAdapter = new OracleDataAdapter(sqlCommand);
//close db connection
dbConnection.closeDB();

//fill dataset
domainAdapter.Fill(ds);
//set datasource
lstSubDomain.DataSource = ds;
//bind data
lstSubDomain.DataBind();
//set visible
lstSubDomain.Visible = true;
 
I think the DataSource for a list should be a DataTable and the "DisplayMember" property of the listbox must be set to the desired ColumnName.
ComboBox1.DataSource = DataSet1.Tables("Suppliers")
ComboBox1.DisplayMember = "ProductName"


Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top