GridView & FormView

Discussion in 'ASP .Net' started by Kyle K., Jul 27, 2006.

  1. Kyle K.

    Kyle K. Guest

    [Config: ASP.NET v2 on WinXP w/ IIS & Visual Studio .NET 2005]

    I would like to build my data pages such that the top of the page
    contains a GridView showing the data with 'Enable Select = true'.

    Below that I would like to have a FormView, that by default is in
    'Insert' mode for creating a new record.

    If the user 'selects' a record in the GridView above, I would like to
    set the FormView to 'Edit' mode with the 'selected' record data loaded
    in it for editing. I would use the built-in editing features of the
    GridView, but the page has fixed width margins that make this almost
    impossible.

    The problem I am having is that during the post-back, the FormView
    always gets reset to 'Insert' mode, no matter what I try.

    Thanks for any help.

    -={ Kyle }=-
    Kyle K., Jul 27, 2006
    #1
    1. Advertising

  2. Hi Kyle,

    I'm not sure what you have tried so far but I am doing the exact same
    thing. In the "SelectedIndexChanged" event of your gridview use the
    following:

    YourFormView.ChangeMode(FormViewMode.Edit)

    The cancel button in your formview will make it go back to insert
    automatically.

    If you are using sorting on your gridview, I advise the following in
    the gridview's "Sorted" event also:

    GridView.SelectedIndex = -1
    YourFormView.ChangeMode(FormViewMode.Insert)

    ...because the sort may leave the same physical row selected but the
    sort will mean a different record will be in it. (This is what is
    happening in my gridview bound to a custom sort anyway)

    Kyle K. wrote:
    > [Config: ASP.NET v2 on WinXP w/ IIS & Visual Studio .NET 2005]
    >
    > I would like to build my data pages such that the top of the page
    > contains a GridView showing the data with 'Enable Select = true'.
    >
    > Below that I would like to have a FormView, that by default is in
    > 'Insert' mode for creating a new record.
    >
    > If the user 'selects' a record in the GridView above, I would like to
    > set the FormView to 'Edit' mode with the 'selected' record data loaded
    > in it for editing. I would use the built-in editing features of the
    > GridView, but the page has fixed width margins that make this almost
    > impossible.
    >
    > The problem I am having is that during the post-back, the FormView
    > always gets reset to 'Insert' mode, no matter what I try.
    >
    > Thanks for any help.
    >
    > -={ Kyle }=-
    cannontrodder, Jul 27, 2006
    #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. Giorgio
    Replies:
    0
    Views:
    3,531
    Giorgio
    Jan 9, 2006
  2. =?Utf-8?B?RGFiYmxlcg==?=

    use Formview cancel commandname to return to GridView Page?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 20, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    5,153
    =?Utf-8?B?RGFiYmxlcg==?=
    Mar 20, 2006
  3. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,942
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  4. Chris

    Formview within Formview

    Chris, May 19, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    503
    Chris
    May 19, 2007
  5. David Thielen

    FormView/Repeater/ Eval(FormView data)

    David Thielen, Jun 16, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    621
    David Thielen
    Jun 16, 2006
Loading...

Share This Page