GridView/FormView (master/details) questions

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,
 
S

Stan

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
 
S

Stan

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).
 

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

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top