Why a TemplateField cannot be a AutoGeneratedField when we have an inherited
It's because AutoGeneratedField is a final class that inherits from
BoundField which inherits DataControlField and TemplateField inherits
DataControlField.
The CreateColumns method is used to create the automatically generated
column fields. Never used this method myself but see Dino Esposito's
article for an example on using CreateColumns() -
http://msdn.microsoft.com/msdnmag/issues/06/05/cuttingedge/default.aspx
The CreateAutoGeneratedColumn method creates one instance of a
AutoGeneratedField.
Say you wanted to autogenerate the fields for a gridview but only
enable sorting on 1 known field called "Supplier" then you'll probably
do something like:
Imports System.Web.UI.WebControls
Namespace SampleControls
Public Class CustomGridView
Inherits GridView
Protected Overrides Function CreateAutoGeneratedColumn(ByVal
fieldProperties As
System.Web.UI.WebControls.AutoGeneratedFieldProperties) As
System.Web.UI.WebControls.AutoGeneratedField
Dim field As AutoGeneratedField =
MyBase.CreateAutoGeneratedColumn(fieldProperties)
'Turn off sorting on non-Supplier columns and leave
sorting only on the Supplier column
If field.HeaderText <> "Supplier" Then
field.SortExpression = ""
End If
Return field
End Function
End Class
End Namespace
Andy