GridView & FormView

K

Kyle K.

[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 }=-
 
C

cannontrodder

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)
 

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

Ask a Question

Similar Threads

FormView 0
FormView disappears 2
FormView insert with UpdatePanel 0
FormView 0
formview edit issue 12
GridView and FormView 1
Link FormView to GridView 0
GridView/FormView (master/details) questions 2

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top