")
Response.write (MyDataReader (0))
Response.write (" td>")
Response.write (" TR>")
Loop
Response.write (" Table>")
You can simplify the above code to make it only:
, and calls the .database. Even if you need to perform special controls for HTML output, you can use a data web control if you can repeat the content of the set on the user interface.
Forgot to check ISPOSTBACK in Page_Load event
One of the most common errors is to check the ISPostBack condition of the page before the data binding. For example, when the DataGrid is in "Edit" mode, ignore the item will result in the original value of the edited value by the original value in the data source. However, this rule has at least one of the main exceptions, see Continuing to use large viewState.
The following is a typical Page_Load event containing the ISPostBack check. Bindgrid () is a routine for importing and setting the data source of the DataGrid, and calls the DATABIND () method.
SUB Page_Load
IF not ispostback.
Bindgrid ()
END IF
End Sub
When you need more flexibility, you still insist on using the automatically generated columns.
If the environment in which the DataGrid needs any special format, or any other web control in the DataGrid, you must close AutoGenerateColumns. Keep the settings of the AutoGenerateColumns property to "True" practice, which is only valid in the simplest DataGrid scheme. However, for almost all actual applications, this property must be set to "false" and specify the column in the columns> segment declared by the DataGrid. Microsoft Visual Studio® .NET users can create these columns using attribute generators in graphical ways.
Note: If the setting of AutoGenerateColumns is kept as "true", and the columns are specified in the DataGrid segment, the repeated settings of the column will eventually be obtained. The system will first display the column of special declarations, followed by all automatically generated columns. Try only using the control ID to reference the controls in the DataGrid project
Many people have not realized that for controls in ItemTemplate under DataGrid (such as TextBox control with "MyTextBox", you cannot use the following code or in the |