Master Details in code

S

Steven Nagy

Hey all,

Scenario:
GridView with ObjectDataSource
DetailsView with ObjectDataSource which refers to the selected value
from teh GridView.
This works fine when all done in design mode without writing a line of
code.
So I am now trying to replicate it in code.
The DetailsView and GridView are still created in design mode with no
properties set (just the bare bones control).

I've got it mostly working except that I am forced to handle everything
at a rudimentary level for the DetailsView control.
For example, I now have to handle the "ModeChanging" event :

void PublisherDetails_ModeChanging(object sender,
DetailsViewModeEventArgs e)
{
PublisherDetails.ChangeMode(e.NewMode);
PublisherDetails.DataBind();
}

If I don't, then clicking the Edit button doesn't switch to edit mode.
Obviously I didn't have to do this before. Other events include
"ItemUpdating" and the GridView needs its "SelectedIndexChanged" event
handled also (to call DataBind() on the DetailsView otherwise it won't
update).

So it seems that I can't find a middle ground of having some of the
work done for me automatically and having to do EVERYTHING. Oh and I'm
not sure what I need to be including in the "ItemUpdating" event to
make it actually update (because its not currently). The
ObjectDataSource should be handling it because I have specified the
methods for my custom objects. I know that they are working correctly
because they were previously working when I had this all working in
design mode.

I do have some code but its currently quite long and isn't a simple
concise example so I don't want to spam you out with it. I guess I'm
more after a recommendation about how to proceed and perhaps find a
balance. Its possible that alot of my headaches are being caused
because the ObjectDataSources are created in code. Perhaps I could
still do everything in code except for the ObjectDataSources? I didn't
want to do that but may have no choice.

Anyways, I appreciate any insights you can muster.

Thanks in advance,
Steven
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top