Hi guys,
I posted my messages before and one of the members helped me a lot. Now I have another problem with the web Interface. I can populate the listboxes with tables from database.The code below populates one of the tables using a for each loop. I can also populate the tables without coding but I want the listboxes to look like a table with rows and columns. And after that I want to select values from each of the listboxes and a textbox to display information on another page. Could you guys help me how to do that. Here is the code.
protected void Page_Load(object sender, EventArgs e)
{
// create the connection string and command string
string connectionString = "Server=.\\SQLEXPRESS;Database=NorthWind;Integrate d Security=SSPI;";
string commandString = "Select * from Customers";
string commandString1 = "Select * from Orders";
string commandString2 = "Select * from Employees";
//pass the strings to the sql data adapter constructor
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, connectionString);
SqlDataAdapter dataAdapter1 = new SqlDataAdapter(commandString1, connectionString);
SqlDataAdapter dataAdapter2 = new SqlDataAdapter(commandString2, connectionString);
// create a data set
DataSet dataSet = new DataSet();
// DataSet dataSet1 = new DataSet();
// fill the dataset object
dataAdapter.Fill(dataSet, "Customers");
//dataAdapter1.Fill(dataSet, "Orders");
//dataAdapter2.Fill(dataSet, "Employees");
// for loop for customer table
foreach (DataRow dtrow in dataSet.Tables["Customers"].Rows)
{
ListBox2.Items.Add(dtrow["CustomerID"].ToString());
ListBox2.Items.Add(dtrow["City"].ToString());
ListBox2.Items.Add(dtrow["CompanyName"].ToString());
ListBox2.Items.Add(dtrow["ContactName"].ToString());
}
}