How to access controls in Edit and Insert templates of DetailsView

Discussion in 'ASP .Net Web Controls' started by The_ShotSpotter_Team, Aug 30, 2005.

  1. Folks,

    Your guidance would be appreciated: I have a DetailsView, and I can use
    FindControl("cmbFoo") to successfully find a DropDownList defined in a
    <ItemTemplate> of a field in a DetailsView. However, if I move cmbFoo to
    either the <EditItemTemplate> or the <InsertItemTemplate>, then
    FindControl("cmbFoo") returns NULL, regardless of what mode the control is in
    (i.e., this fails in read-only mode, in edit mode and in insert mode).

    How do I access my cmbFoo when its home is the <EditItemTemplate> or the
    <InsertItemTemplate> of a field in a DetailsView?

    Thanks in advance.

    Regards,
    /s/ James
     
    The_ShotSpotter_Team, Aug 30, 2005
    #1
    1. Advertising

  2. The_ShotSpotter_Team

    Brock Allen Guest

    I suspect the problem is that you're calling FindControl before the DetailsView
    is DataBound. Try doing this call in the DataBound event.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Folks,
    >
    > Your guidance would be appreciated: I have a DetailsView, and I can
    > use FindControl("cmbFoo") to successfully find a DropDownList defined
    > in a <ItemTemplate> of a field in a DetailsView. However, if I move
    > cmbFoo to either the <EditItemTemplate> or the <InsertItemTemplate>,
    > then FindControl("cmbFoo") returns NULL, regardless of what mode the
    > control is in (i.e., this fails in read-only mode, in edit mode and in
    > insert mode).
    >
    > How do I access my cmbFoo when its home is the <EditItemTemplate> or
    > the <InsertItemTemplate> of a field in a DetailsView?
    >
    > Thanks in advance.
    >
    > Regards,
    > /s/ James
     
    Brock Allen, Aug 30, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William LaMartin

    DetailsView edit and insert row widths

    William LaMartin, Jan 22, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    12,482
    mrpink
    Mar 29, 2009
  2. cannontrodder
    Replies:
    1
    Views:
    740
    cannontrodder
    Jul 25, 2006
  3. cheshire2k
    Replies:
    0
    Views:
    637
    cheshire2k
    Nov 9, 2006
  4. eagle

    Insert & Insert/Repeat buttons in a detailsview

    eagle, Jul 12, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    1,071
    eagle
    Jul 12, 2007
  5. Feege
    Replies:
    0
    Views:
    485
    Feege
    Dec 20, 2005
Loading...

Share This Page