Creating a Web Interface in ASP.NET using C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • koonda
    New Member
    • Oct 2006
    • 34

    #1

    Creating a Web Interface in ASP.NET using C#

    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(objec t sender, EventArgs e)
    {
    // create the connection string and command string

    string connectionStrin g = "Server=.\\SQLE XPRESS;Database =NorthWind;Inte grated 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, connectionStrin g);
    SqlDataAdapter dataAdapter1 = new SqlDataAdapter( commandString1, connectionStrin g);
    SqlDataAdapter dataAdapter2 = new SqlDataAdapter( commandString2, connectionStrin g);
    SqlDataAdapter dataAdapter3 = new SqlDataAdapter( commandString2, connectionStrin g);

    // create a data set

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

    dataAdapter.Fil l(dataSet, "Customers" );
    dataAdapter1.Fi ll(dataSet, "Orders");
    dataAdapter2.Fi ll(dataSet, "Employees" );
    dataAdapter3.Fi ll(dataSet, "Products") ;






    // for loop for customer table

    foreach (DataRow dtrow in dataSet.Tables["Customers"].Rows)
    {
    ListBoxCustomer s.Items.Add(dtr ow["CustomerID "].ToString());
    ListBoxCustomer s.Items.Add(dtr ow["City"].ToString());
    ListBoxCustomer s.Items.Add(dtr ow["CompanyNam e"].ToString());
    ListBoxCustomer s.Items.Add(dtr ow["ContactNam e"].ToString());
    }


    // for loop for Employees table

    foreach (DataRow dtrow in dataSet.Tables["Employees"].Rows)
    {
    ListBoxEmployee s.Items.Add(dtr ow["EmployeeID "].ToString());
    ListBoxEmployee s.Items.Add(dtr ow["LastName"].ToString());
    ListBoxEmployee s.Items.Add(dtr ow["FirstName"].ToString());

    }

    // for loop for order table


    foreach (DataRow dtrow in dataSet.Tables["Orders"].Rows)
    {
    ListBoxOrders.I tems.Add(dtrow["OrderID"].ToString());
    ListBoxOrders.I tems.Add(dtrow["CustomerID "].ToString());
    ListBoxOrders.I tems.Add(dtrow["EmployeeID "].ToString());

    }

    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.Redire ct("Default2.as px"); // another page to display

    }


    I appreciate your help.

    Koonda
Working...