467,161 Members | 904 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

GridView.Columns.Insert Problems

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?
Feb 9 '07 #1
  • viewed: 2573
Share:
1 Reply
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?

"Harry Keck" wrote:
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?
Feb 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Robert Smith jr. | last post: by
3 posts views Thread by NateDawg | last post: by
reply views Thread by Frank | last post: by
10 posts views Thread by =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post: by
11 posts views Thread by Ed Dror | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.