Access controls inside GridView template at designtime

J

jdlwright

Hi, I need my control to access other controls that are located in the
ItemTemplate of a GridView - at designtime.

I had success in the past with DataGrid, doing this by calling
FindControl at design-time - however it doesn't work with GridView.

So basically in the EditValue method of my UITypeEditor I would access
the DataGrid with FindControl and then call FindControl on it to get at
the control I was after.

Is there anyway to access controls that are in a GridView template?

Many thanks,
Jim
 
N

Nathaniel Greene

Obvious question, but have you had your designer check your control's Parent
? and see who it is and then iterate until you've found your ItemTemplate?
 
J

jdlwright

Thanks for replying - unfortunately I have tried looking at Parent - it
only contains my control and the GridView. As far as I can see,
there's no way to access the ItemTemplate, as it's not listed in
GridView.Controls (in fact, GridView.Controls.Count==0).
 
P

Peter Zolja

Hi, I need my control to access other controls that are located in the
ItemTemplate of a GridView - at designtime.

Does it work at runtime? I mean, can you find other controls in the
ItemTemplate when you run the application? Could you post a small test
program? (A lot of times just building a small test program helps you find
the solution :)

Peter.
 
J

jdlwright

Does it work at runtime? I mean, can you find other controls in the
ItemTemplate when you run the application? Could you post a small test
program? (A lot of times just building a small test program helps you find
the solution :)

Peter.

You're right it does usually help, Peter. I've had to give up on this
and assume it's just down to the difference between .NET 1's DataGrid
and GridView. Logically I'm unsure why DataGrid _would_ provide the
controls in it's template via FindControl at design time, I guess it
was just a happy side-effect of how it was made - and I have no reason
to expect the same from GridView. Nevermind, I made a compromise
instead.

Thanks though,
Jim
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top