Default edit mode problem

Discussion in 'ASP .Net Web Controls' started by Chris, May 29, 2006.

  1. Chris

    Chris Guest

    I have a treeview in the edit template of my formview but not in the item
    templete. It is populated programatically with the code below. When the
    default mode is readonly this code works fine. When I set the default to
    edit I get a 'Object reference not set to an instance of an object' on the
    line that tries to find the control. The Formview becomes active when a row
    is selected in a gridview.

    If FormView1.CurrentMode = FormViewMode.Edit Or FormView1.CurrentMode =
    FormViewMode.Insert Then
    Dim tw As TreeView
    tw = New TreeView()
    tw = FormView1.Row.FindControl("treeview1")
    tw.Nodes.Clear()
    GetFolders(Server.MapPath(""), tw.Nodes)
    End If

    When I set it to readonly it goes into readonly mode it works fine. But
    there is no treeview in the read only mode. When I select the edit button it
    goes into edit mode and finds the treeview. It is only in the default mode.
    Can anyone help? Regards, Chris.
     
    Chris, May 29, 2006
    #1
    1. Advertising

  2. Chris

    Guest

    Where are you calling this code from? Page_Load?

    It will be safest to call the code above from within the ItemCreated
    event handler of the FormView. This way you know that the controls
    within the row (HeaderRow, FooterRow, BottomPagerRow) has created.

    Regards,
    Andy
     
    , May 30, 2006
    #2
    1. Advertising

  3. Chris

    Chris Guest

    It is getting called from the itemcreated. That's what is confusing me. The
    control should have been added.

    <> wrote in message
    news:...
    > Where are you calling this code from? Page_Load?
    >
    > It will be safest to call the code above from within the ItemCreated
    > event handler of the FormView. This way you know that the controls
    > within the row (HeaderRow, FooterRow, BottomPagerRow) has created.
    >
    > Regards,
    > Andy
    >
     
    Chris, May 30, 2006
    #3
  4. Chris

    Guest

    Very strange, it's almost as if the FormView is not loading the
    EditItemTemplate properly when you set the DefaultMode to Edit.

    Regards,
    Andy
     
    , May 30, 2006
    #4
    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. John J Lee
    Replies:
    3
    Views:
    549
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    523
    Edward Loper
    Aug 7, 2007
  3. Frank Kurka
    Replies:
    8
    Views:
    342
  4. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    450
    Jaime Stuardo
    Apr 7, 2006
  5. jobs at webdos
    Replies:
    0
    Views:
    522
    jobs at webdos
    Oct 9, 2006
Loading...

Share This Page