By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,494 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,494 IT Pros & Developers. It's quick & easy.

GridView & FormView

P: n/a
[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 }=-
Jul 27 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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 }=-
Jul 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.