How to: Enable Default Paging in the GridView Web Server Control
https://msdn.microsoft.com/en-us/library/y71xk4a7(v=vs.100).aspx
To enable paging in the Properties window
-
Select the GridView control, and in the Properties window, set AllowPaging property to true.
GridView Class
DataBind
Use the DataBind() method to bind data from a data source to the GridView control. This method resolves all data-binding expressions in the active template of the control.
The DataBind method is called automatically if the DataSourceID property of the GridView control refers to a valid data source control.
Instead of manually calling the DataBind method, you can use model binding with your DataBind control by setting the SelectMethod property to the name of a method that returns data for the GridView. The GridView is then automatically populated with the data that is returned from the select method. Model binding can simplify your code for working with data. For more information, see Model Binding and Web Forms.
DataSource
When you set the DataSource property, the ValidateDataSource method is called.
In addition, if the data-bound control has already been initialized, the OnDataPropertyChanged method is called to set the RequiresDataBinding property to true
.
This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.
动态添加新的列
private void AddViewColumns() { string script = @"$(function () { var selector = '#' + '" + logsGridView.ClientID + @"' + ' :input[type=""image""]'; $(selector).attr('class', 'grid-action view'); } ); "; ScriptManager.RegisterClientScriptBlock(logsGridView, logsGridView.GetType(), "msBug", script, true); }