GridView.Columns.Insert Problems

G

Guest

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?
 
G

Guest

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top