Can't change mode in FormView

Discussion in 'ASP .Net' started by staeri@gmail.com, Apr 13, 2006.

  1. Guest

    I have a FormView with DefaultMode="Insert".

    I want to change this to DefaultMode="Edit" with code but this doesn't
    work. It's still in insert mode. I've used the following code:

    Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    FormView1.ChangeMode(FormViewMode.Edit)
    FormView1.DefaultMode = FormViewMode.Edit
    End Sub

    What is wrong? If I change to DefaultMode="Edit" manually in the aspx
    file it works but not with code.

    Very grateful for fast help!

    Regards,

    S
    , Apr 13, 2006
    #1
    1. Advertising

  2. Guest

    When I change to the following code it works:

    Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Me.Load
    If (Not IsPostBack) Then
    If Len(Request.QueryString("Mode")) > 0 Then
    FormView1.ChangeMode(FormViewMode.Edit)
    FormView1.DefaultMode = FormViewMode.Edit
    End If
    End If
    End Sub

    What does Handles Me.Load do?

    Regards,

    S
    , Apr 13, 2006
    #2
    1. Advertising

  3. Handles Me.Load actually causes your Page_Load method to execute. That was
    your problem earlier when you couldn't change values.
    --
    Christopher A. Reed
    "The oxen are slow, but the earth is patient."

    <> wrote in message
    news:...
    > When I change to the following code it works:
    >
    > Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Me.Load
    > If (Not IsPostBack) Then
    > If Len(Request.QueryString("Mode")) > 0 Then
    > FormView1.ChangeMode(FormViewMode.Edit)
    > FormView1.DefaultMode = FormViewMode.Edit
    > End If
    > End If
    > End Sub
    >
    > What does Handles Me.Load do?
    >
    > Regards,
    >
    > S
    >
    Christopher Reed, Apr 17, 2006
    #3
  4. Guest

    But I've user Page_Load in other situations before without the Me.Load
    and everything has been executed then.

    Should Me.Load always be used?
    , Apr 20, 2006
    #4
  5. It may have something to do with the AutoEventWireup attribute in the @Page
    directive. Since I'm a C# programmer, I'm not really sure, but I'll
    research it and reply back (unless a VB guru can respond faster).
    --
    Christopher A. Reed
    "The oxen are slow, but the earth is patient."

    <> wrote in message
    news:...
    > But I've user Page_Load in other situations before without the Me.Load
    > and everything has been executed then.
    >
    > Should Me.Load always be used?
    >
    Christopher Reed, Apr 20, 2006
    #5
    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:
    456
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    444
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    502
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    415
    Edward Loper
    Aug 9, 2007
  5. jobs at webdos
    Replies:
    0
    Views:
    445
    jobs at webdos
    Oct 9, 2006
Loading...

Share This Page