2

I made this work, but not in an appropirate way.

I'm working with .NET 4.0 and these would be my needs:

I work with a big bunch of gridviews that essentially shows the same kind of controls and works in the very same way.

What i've tried is creating a custom Templatefield that, through desing-time properties, indicates the templateField's type and it's databind field name from DDBB.

For instance, i have a lot of gridviews that contains templatefields with identical controls, only the DDBB column name is different. I would like to have something like this:

<asp:GridView ID="GridView" runat="server">
        <Columns>
          <CustomPrefix:CustomTemplateField type="DateField" 
          bindFieldName="DDBB.Colum_name" editable="true">
        </Columns>

</asp:GridView>

And this, would be coded in code-behind by adding a Itemtemplate (with a label for showing the date from DDBB) and an EditItemTemplate (because of editable property is setted to true) with a textbox and an ajax_CalendarExtender.

This way, i could reuse this implementation trhough mutiple gridviews, since i provide unique differences through properties.

One of the concrete problems i had, is that in templateField constructor it cannot instanciates its ItemTemplate and EditItemTemplate since desing-time properties are not setted unitl later.

I don't really know what would be the appropirate way to do this (if is possible). I checked server controls, templated controls...

Some guidance would be very welcome

I hope this is understandable.

Inquisitor
  • 21
  • 3

0 Answers0