Use the GridView control

Original link: http://www.cnblogs.com/liuzhiyi7288/archive/2009/02/17/1392674.html

GridView control typical data-bound controls, such controls and data source control to be used in conjunction with the corresponding data to display, in which today's data source controls are sqlDataSourse.

Binding data-bound controls and data source control steps of:

1, first establish a connection to a database, the database in any of a drag to the interface table, the aim is to connect a string configuration database.

Table 2, will want to show data objects (database) to drag interface, this time in the interface, VS automatically creates is divided into two GridView controls and SqlDataSourse.

3, the source of the configuration data of the data source control, smart prompt button click, select the configuration Source: connecting the selected character string database (corresponding to the configuration file), to enter the next table, and then select the fields to be displayed, click to complete in the upper right corner of the GridView smart prompt, select the data source, select the default data source name to just configured.

4, headText manually modify the value of each field, only the display name attribute refers to the field, so this property to characters.

5, manually set the paging and other functions, to suggest that, after clicking on the smart paging, sorting, selecting three options are on the hook can also be in the property pageSetting, a more detailed set of attributes, such as setting display per page lines, etc., as well as the display format.

6, is a field in the table can be set to display a format field, in the IntelliSense, editing entries can be selected dataStringFormat, such as date, currency format, and so on.

7, implemented manually associate a field, first column settings as a template in the GridView in this column, and then edit the template column, this time to add another data-bound control DrowDownList, this control should be jointly and data source controls for data show the following configuration data DrowDownList source, and the step of establishing a data source control GridView is the same; End established, and then bind to a data source control to DrowDownList; then edit the bindings, the selected control in this GridView ID and the ID of the MO column corresponding to a column.

8, display data is implemented by the code: the Label lblTest = ((the DropDownList) SENDER) .Parent.FindControl ( "Label2") AS the Label;
        lblTest.Text = ((the DropDownList) SENDER) .SelectedItem.ToString ();
  then DrowDownList the visible property to false to implement controls to hide.

Reproduced in: https: //www.cnblogs.com/liuzhiyi7288/archive/2009/02/17/1392674.html

Guess you like

Origin blog.csdn.net/weixin_30221425/article/details/94796376