Access controls inside GridView template at designtime

Discussion in 'ASP .Net Building Controls' started by jdlwright, Jan 26, 2007.

  1. jdlwright

    jdlwright Guest

    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
     
    jdlwright, Jan 26, 2007
    #1
    1. Advertisements

  2. 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?
     
    Nathaniel Greene, Jan 26, 2007
    #2
    1. Advertisements

  3. jdlwright

    jdlwright Guest

    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).
     
    jdlwright, Jan 27, 2007
    #3
  4. jdlwright

    Peter Zolja Guest

    Hi, I need my control to access other controls that are located in the
    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.
     
    Peter Zolja, Jan 31, 2007
    #4
  5. jdlwright

    jdlwright Guest

    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
     
    jdlwright, Feb 1, 2007
    #5
    1. Advertisements

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