Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > AutoGeneratedField

Reply
Thread Tools

AutoGeneratedField

 
 
Bora
Guest
Posts: n/a
 
      05-23-2007
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)
and
AutoGeneratedField CreateAutoGeneratedColumn(AutoGeneratedFieldProper ties
fieldProperties)
?

Regards,
Bora Inceler

 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      05-29-2007
> Why a TemplateField cannot be a AutoGeneratedField when we have an inherited
> GridView class?


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/is...e/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.AutoGeneratedFieldProper ties) 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

On 23 May, 11:24, "Bora" <(E-Mail Removed)> wrote:
> 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)
> and
> AutoGeneratedField CreateAutoGeneratedColumn(AutoGeneratedFieldProper ties
> fieldProperties)
> ?
>
> Regards,
> Bora Inceler



 
Reply With Quote
 
 
 
 
Bora
Guest
Posts: n/a
 
      06-12-2007
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

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>> Why a TemplateField cannot be a AutoGeneratedField when we have an
>> inherited
>> GridView class?

>
> 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/is...e/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.AutoGeneratedFieldProper ties) 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
>
> On 23 May, 11:24, "Bora" <(E-Mail Removed)> wrote:
>> 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)
>> and
>> AutoGeneratedField CreateAutoGeneratedColumn(AutoGeneratedFieldProper ties
>> fieldProperties)
>> ?
>>
>> Regards,
>> Bora Inceler

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments