By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,283 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,283 IT Pros & Developers. It's quick & easy.

Creating a Web Interface in ASP.NET using C#

P: 34
Hi guys,

I posted a message before and I got some help from the forum. I have a database in SQL Server and I wanted to create a web interface in C#. I had 4 Listbox controls and a Textbox and two buttons for this. What I want to do is to select values from 4 Listbox controls and input some text in the textbox i.e year to display information on another page including all the information from $ listboxes too. I have no idea how to program this part. I have populated the 4 Listboxes from the database tables and I want to select some values from these listboxes and display information on another page. Could somebody help me in this regard. Below is the code I developed so far with your help.

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);
SqlDataAdapter dataAdapter3 = new SqlDataAdapter(commandString2, connectionString);

// create a data set

DataSet dataSet = new DataSet();
// fill the dataset object

dataAdapter.Fill(dataSet, "Customers");
dataAdapter1.Fill(dataSet, "Orders");
dataAdapter2.Fill(dataSet, "Employees");
dataAdapter3.Fill(dataSet, "Products");

// for loop for customer table

foreach (DataRow dtrow in dataSet.Tables["Customers"].Rows)

// for loop for Employees table

foreach (DataRow dtrow in dataSet.Tables["Employees"].Rows)


// for loop for order table

foreach (DataRow dtrow in dataSet.Tables["Orders"].Rows)


And here is the Event Handler which I want to select values from the listboxes and a taxtbox and redirect the user to display relevant information on another page. Unfortunately I don't know how to code this part.

protected void BtnSubmit_Click(object sender, EventArgs e)

Response.Redirect("Default2.aspx"); // another page to display


I appreciate your help.

Jan 14 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.