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