how can i display data in listbox?
-
i have a database of lists of subjects...then in my module, i want to display all the subjects that i recorded in the listbox... how can i do it? i already connect my dataset in the connection wizard but i can't display it in the listbox.
use the following coding... String sql = "SELECT Category Name FROM Categories"; OleDbConnection con = new OleDbConnection(connectionString); OleDbCommand cmd = new OleDbCommand(sql,con); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable dt =new DataTable(); con.Open(); da.Fill(dt); ListBox1.DataSource = dt; ListBox1.DataBind();
-
use the following coding... String sql = "SELECT Category Name FROM Categories"; OleDbConnection con = new OleDbConnection(connectionString); OleDbCommand cmd = new OleDbCommand(sql,con); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable dt =new DataTable(); con.Open(); da.Fill(dt); ListBox1.DataSource = dt; ListBox1.DataBind();