473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Creating a Web Interface in ASP.NET using C#

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)
{
ListBoxCustomers.Items.Add(dtrow["CustomerID"].ToString());
ListBoxCustomers.Items.Add(dtrow["City"].ToString());
ListBoxCustomers.Items.Add(dtrow["CompanyName"].ToString());
ListBoxCustomers.Items.Add(dtrow["ContactName"].ToString());
}


// for loop for Employees table

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

}

// for loop for order table


foreach (DataRow dtrow in dataSet.Tables["Orders"].Rows)
{
ListBoxOrders.Items.Add(dtrow["OrderID"].ToString());
ListBoxOrders.Items.Add(dtrow["CustomerID"].ToString());
ListBoxOrders.Items.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.Redirect("Default2.aspx"); // another page to display

}


I appreciate your help.

Koonda
Jan 14 '07 #1
0 1394

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

Similar topics

1
by: Matthew Clubb | last post by:
Hi, I need help developing an expanding form I've decided that a use of PHP, Mysql and Javascript is the best platform for creating a selection of database interfaces which I'm trying to build...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
4
by: SH | last post by:
I wish to create a program (really a Windows Service) that sits and waits for a client PC to communicate with it, but I can't come up with a good method of doing so. I want to have a service...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
16
by: Asaf | last post by:
I am trying to create and use a COM object with C#.NET 2005. The assembly is set to "Register for COM interop" but when I am trying to call it from VB on Word 2003 I am getting this error: ...
1
by: Marcel Hug | last post by:
Hi NG ! I have already written a task about MVC and I tried to get the best informations together. I would like to implement the MVC pattern and it work on the way I did it. At first i know the...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
31
by: JoeC | last post by:
I have read books and have ideas on how to create objects. I often create my own projects and programs. They end up getting pretty complex and long. I often use objects in my programs they are...
0
by: hypeartist | last post by:
I need to create interface "on-the-fly" so it "reflects" some class (mainly it's properties). Here's how I do this: public class Transformer { private const TypeAttributes...
6
by: Chris Carlen | last post by:
Hi: I have an embedded system, platform: TI TMS320F2812 32-bit integer DSP. A module (.c file) contains external (to the funcs in that module) variables which are used to affect the operation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.