Discussion in 'ASP .Net Building Controls' started by Bora, May 23, 2007.

  1. Bora

    Bora Guest

    Why a TemplateField cannot be a AutoGeneratedField when we have an inherited
    GridView class?

    What is the difference between
    System.Collections.ICollection CreateColumns(PagedDataSource dataSource,
    bool useDataSource)
    AutoGeneratedField CreateAutoGeneratedColumn(AutoGeneratedFieldProperties

    Bora Inceler
    Bora, May 23, 2007
    1. Advertisements

  2. Bora

    CaffieneRush Guest

    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

    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() -

    The CreateAutoGeneratedColumn method creates one instance of a
    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

    Dim field As AutoGeneratedField =

    '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

    CaffieneRush, May 29, 2007
    1. Advertisements

  3. Bora

    Bora Guest

    Thanks for the response.

    All the things you told are fair and self-definitive.

    Why I can't autogenerate custom fields? AutoGeneratedField is sub-class for
    BoundField but I can't use other BoundField inherited class. Forcing to
    return AutoGeneratedField is against OO for autogeneration. That should be
    fixed. I can't autogenerate a CheckBoxField or TemplateField. (I not have my
    own autogeneration using CreateColumns, so not bothering with this now) But
    the AutoGeneratedField class should be dropped and DataControlField should
    be used for CreateAutoGeneratedColumn method.

    Am I wrong?

    Bora, Jun 12, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.