0% found this document useful (0 votes)
14 views

DropDown - GridView - DataList Data Binding

This document discusses binding a dropdownlist, datalist, and gridview to display invoice data from a Northwind database. It describes adding these controls to an ASP.NET page and configuring them to display customer and invoice information from different tables, with the controls updating dynamically based on the selected customer in the dropdownlist. The gridview displays invoice details, while the datalist shows related shipping and billing data.

Uploaded by

Abby P
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

DropDown - GridView - DataList Data Binding

This document discusses binding a dropdownlist, datalist, and gridview to display invoice data from a Northwind database. It describes adding these controls to an ASP.NET page and configuring them to display customer and invoice information from different tables, with the controls updating dynamically based on the selected customer in the dropdownlist. The gridview displays invoice details, while the datalist shows related shipping and billing data.

Uploaded by

Abby P
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

ASP Essential: Data Binding a DropDownList, DataList, & GridView (Northwind Invoices)

In this next data essential we will be working with our trusty drop-down list and gridview, and will be introducing
another new asp.net data element: the datalist. The datalist web control displays data in a format that you can define
using templates and styles. The datalist control is useful for data in any repeating structure, such as a table; it can display
rows in different layouts, such as ordering them in columns or rows (which we will be doing).

Start by creating a new web form with master page named “Invoices.aspx”, adding the link in the Site2.Master, and
adding the following layout from the text file provided on Portal:
You may opt to set this as the start page for the project once again so it is easy to navigate to when testing.

From here we will start working on our drop-down. We will be using the Invoices table as our main point this project.

Our Invoices table has a lot of options that we will eventually get to, but for the drop-down list we will just start out with
our customerID and customer name. Our datalist and gridview will use the customerID property from the drop-down list
to bind their data.

From here, we will add in our data list and our gridview. I know we usually work top down on our page, but in this case,
we are going to configure our gridview first, and then come back to our datalist.
We are going to create another data set based on the following:
We should be able to choose a customer from the dropdown and see the invoice information change in the gridview.
Some customers have more invoices than others, so enabling paging is important for those who have PAGES of invoices.

Once we are able to confirm we can navigate through our invoices, it is time to add some final touches (aka our datalist).

We did not include the shipping/billing information in the gridview. We will include it on the page in the datalist. (Kinda
an important thing for the invoices!) There are a few options when doing this. You can add another data set, modify the
previous one, add a data set that is talking to a different customer table, etc. This example shows how you can connect
to a separate table and still pull data based on the drop-down.
Once finished, we should get an invoice page where we are binding 2 data controls to (1 or 2) data sets and dynamically
display information based on a drop-down web control.

You might also like