Non-code data-binding operations on controls in C # (WEB FORM)

Source: Internet
Author: User

Use SQL Server's example database Northwind for instructions.
Effect: The program updates the contents of the GridView Product Information list according to the user's selected product name

Add 1 dropdownlist,1 to a gridview,2 on the Web Form SqlDataSource

Data binding method: When a control is selected, a small square appears on the control with a black triangle on it, the corresponding data binding items will appear after the click, the key operation of data binding is this, the following relevant binding time no longer repeat.

SqlDataSource1
SELECT [ProductID], [ProductName] from [Products]

DropDownList1
Data source Selection SqlDataSource1, display data segment: ProductName, select data segment: ProductID
Select AutoPostBack

SqlDataSource2
SELECT [OrderID], [ProductID], [UnitPrice], [Quantity] from [the Order Details] WHERE ([ProductID] = @ProductID)
Description: Select the ' WHERE ' button when configuring the data source, select ' ProductID ', source select ' control ', and controls ID to DropDownList1

GridView1
Data Source Selection SqlDataSource2

It is important to have two points in the above data binding (the blue section above), and the first is to select AutoPostBack to submit to the server when DropDownList1 changes the selected content. The second is to select the ' WHERE ' button when configuring the data source SqlDataSource2 to allow SqlDataSource2 to be associated with DropDownList1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.