Binding Data Bound Controls<绑定到数据绑定控件,即两个控件绑定在一起,以影响另一个控件中的数据显示的效果>
Often you will need to set up a control from which the user can select a value and have it affect the data displayed in another control. In a sense they are "bound together"//捆绑在一起. In this lesson you will bind//绑定 a DropDownList control to the GridView control. The DropDownList control will contain a list of states//一组"州"列表项, and the value you select from this control will be used in a WHERE clause//where<条件>分句 for loading data//载入数据 into the GridView.
1. Below the Label type//键入<就是打字> "Select State ". Then, from the Toolbox, drag a DropDownList control onto the design surface//设计界面,而不是代码页面 next to "Select State".

2. You need to add states //列表项to the DropDownList control. In the DropDownList Tasks menu click Edit Items//编辑列表项.
3. There are authors in the database table from California and Utah. In the ListItems Collection Editor //见下图打开的对话框的标题栏dialog, click Add. For Text enter "CA"//California的缩写"即美国加州的缩写"<上一句话中有出现>. Repeat this step to add "UT"//Utah的综写"即美国犹他州的缩写"<<见上一句话>, and then click OK.

4. In the DropDownList Tasks menu check Enable AutoPostBack.//见上面第一个图的浮动的小窗口 This will cause the Web page to reload when the user selects a menu item//菜单项, which in turn //接下来,依次will refresh the GridView with data filtered //过虑for the selected state.//所选择的"州"选项
5. In the Properties window change the DropDownList control's (ID) property to "stateDropDownList". Press CTRL+S to save the changes.
6. Open the authorsSqlDataSource Tasks menu and select Configure Data Source.
The value of the DropDownList control must be fed into //注入the GridView control, and this happens by modifying the SELECT statement //select 语句for the SqlDataSource control. Specifically, a WHERE clause//where条件分句 must be added that contains the DropDownList's selected value.
7. Click Next. At the Configure the Select Statement step, click WHERE.
8. In the Add WHERE Clause dialog//添加where条件分句对话框, for Column //列select state. For Source select Control//控件. For Control ID select stateDropDownList. For Default value enter "CA". Click Add and then click OK.

9. Because you have modified the SELECT statement you should also generate //产生,发生new INSERT, DELETE, and UPDATE commands. Click Advanced.
10. Select Generate Insert, Update, and Delete statements//语句, and then click OK.

11. Click Next and then click Finish. When prompted to//提示 refresh Fields and Keys for the GridView, click No until the dialog clears. Press F5 to run the application. Select a different state //州value and notice how the page reloads //重新载入and filters //过虑the authors in the GridView control.

With previous versions of Visual Studio this would have required a lot more time and effort. The new VWD data binding features, especially at design-time, greatly simplify the task of building data-driven Web interfaces.
浙公网安备 33010602011771号