![]() |
GridView/FormView (master/details) questions
Hi,
I have a hard time finding an example with GridView and FormView on the same page. So I'm hoping that someone will be able to help me with the following: 1) How do I refresh GridView after Insert, Update, and Delete in a linked FormView? That is, I'd like the GridView to show updates made to a row, show a newly added row, and remove a deleted row. 2) How do I force the FormView to display in InsertMode if no items are present in the associated GridView? I know that I need to call ChangeMode() on the FormView but I'm not sure where. I tried Selected event of the associated ObjectDataSource with "if (e.RowsAffected < 1) FormView.ChangeMode(FormViewMode.Insert)" but this does not seem to work. The ObjectDataSourceStatusEventArgs.RowsAffected is always -1 regardless of how many rows are displayed in the GridView. So I must be checking it in the wrong place. Any help will be greatly appreciated. Thanks, |
Re: GridView/FormView (master/details) questions
On 26 Mar, 22:19, "dan" <d...@nocompany.com> wrote:
> Hi, > > I have a hard time finding an example with GridView and FormView on the same > page. So I'm hoping that someone will be able to help me with the following: > > 1) How do I refresh GridView after Insert, Update, and Delete in a linked > FormView? > That is, I'd like the GridView to show updates made to a row, show a newly > added row, and remove a deleted row. > > 2) How do I force the FormView to display in InsertMode if no items are > present in the associated GridView? > I know that I need to call ChangeMode() on the FormView but I'm not sure > where. *I tried Selected event of the associated ObjectDataSource with "if > (e.RowsAffected < *1) FormView.ChangeMode(FormViewMode.Insert)" but this > does not seem to work. *The ObjectDataSourceStatusEventArgs.RowsAffected is > always -1 regardless of how many rows are displayed in the GridView. So I > must be checking it in the wrong place. > > Any help will be greatly appreciated. > Thanks, 1) Execute the GridView's DataBind() method in the event handlers for the FormView's ItemInserted, ItemUpdated and ItemDeleted events. 2) In the Page_load event handler execute the FormView's ChangeMode() method if the GridView's Rows.Count property is zero. HTH |
Re: GridView/FormView (master/details) questions
On 29 Mar, 00:50, Stan <goo...@philphall.me.uk> wrote:
> On 26 Mar, 22:19, "dan" <d...@nocompany.com> wrote: > > > > > > > Hi, > > > I have a hard time finding an example with GridView and FormView on the same > > page. So I'm hoping that someone will be able to help me with the following: > > > 1) How do I refresh GridView after Insert, Update, and Delete in a linked > > FormView? > > That is, I'd like the GridView to show updates made to a row, show a newly > > added row, and remove a deleted row. > > > 2) How do I force the FormView to display in InsertMode if no items are > > present in the associated GridView? > > I know that I need to call ChangeMode() on the FormView but I'm not sure > > where. *I tried Selected event of the associated ObjectDataSource with "if > > (e.RowsAffected < *1) FormView.ChangeMode(FormViewMode.Insert)" but this > > does not seem to work. *The ObjectDataSourceStatusEventArgs.RowsAffected is > > always -1 regardless of how many rows are displayed in the GridView. So I > > must be checking it in the wrong place. > > > Any help will be greatly appreciated. > > Thanks, > > 1) Execute the GridView's DataBind() method in the event handlers for > the FormView's ItemInserted, ItemUpdated and ItemDeleted events. > > 2) In the Page_load event handler execute the FormView's ChangeMode() > method if the GridView's Rows.Count property is zero. > > HTH- Hide quoted text - > > - Show quoted text - Correction: It might be safer to use the GridView DataBound event rather than the Page_Load event in (2). |
| All times are GMT. The time now is 12:01 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.