GridView/FormView (master/details) questions

  • Thread starter Thread starter dan
  • Start date Start date
D

dan

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,
 
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.RowsAffectedis
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
 
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).
 
Back
Top