views:

519

answers:

1

How do I add TemplateField control to the beginning of the DetailsView Fields collection?

Here is my code..

TemplateField tf = new TemplateField();
...
...
dv.Fields.Add(tf);

This adds to the very end of the DetailsView control. I tried dv.Fields(0) but there is no Add method available. I noticed that we have dv.Fields.RemoveAt but we do not have dv.Fields.AddAt...

Any ideas???

+2  A: 

To Add the field at the beginning, use the INSERT method as follows:

TemplateField tf = new TemplateField();
...
...
dv.Fields.Insert(0, tf);
Jose Basilio
THANK YOU !!!!!!!!!!!!!!!!!!
dotnet-practitioner
This worked right away... Guys like you make SO very useful !!!!
dotnet-practitioner