GridView.Columns.Insert Problems

H

Harry Keck

I have a GridView that I dynamically add columns to in code. The way that my
code is written, everything works properly if I use GridView.Columns.Add to
simply add the columns to the end of the collection. However, if I use
GridView.Columns.Insert to inject the columns in the middle of the existing
columns, I see lots of exceptions when I page the GridView, because certain
controls contained within the grid are mysteriously absent? Can anyone
explain what the difference is between Add and Insert that would cause
problems?
 
H

Harry Keck

I think I can see what is happening, but I still do not know why. My
GridView has a number of TemplateFields declared directly in the aspx. I
then use GridView.Columns.Insert to add a couple of BoundFields to the grid.
Any subsequent time that I bind data to the GridView after calling Insert,
all of the TemplateFields are empty. If I change my code to use Collumns.Add
in place of Collumns.Insert, the Template Fields do not empty. What is going
on?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top