Wierd DataSource interaction

D

daveh551

Apologies in advance for this being so long, but I can't seem to find
a way to simplify it more than this.

I have a 6-row Details View that defaults to insert mode. There are
really only two rows relevant to this discussion.

One is a checkbox field called "AlwaysValid". If checked, then this
particular entry is valid at all hours of all days. If not checked,
then there is a second row called "Valid Times" that expands into a
user control for indicating exactly which hours this entry is valid
for. If the AlwaysValid box is checked, then I want the row for the
"Valid Times" control to be invisible.

In my ItemCreated event handler, I set some default values for a new
entry, which includes checking the AlwaysValid box. In the PageLoad
handler, I look at the value of AlwaysValid, and turn Visible for the
ValidTimes row on or off accordingly

In testing with this page in isolation, things seem to work
swimmingly: I get a DataBinding event, followed by the ItemCreated
event in which AlwaysValid is set, followed by DataBound, and then
PageLoad. The DetailsView displays without the ValidTimes row, just
the way I want.

The DataSource that the DetailsView is bound to is an ObjectDataSource
using the Get method of a standard TableAdapter constructed using the
DataSet tools in VS2008 (though it is using a view to get expansion of
some foreign fields, but it's straight forward). When I run the page
in isolation, the Session variable for UserId, which is a parameter to
the Select method of the DataSource, is not set. When I run the page
within the website, that variable is set, and the page starts mis-
behaving.

I've set event handlers and break points, and this is what happens.
After the PageLoad fires, the DataSource Load event fires, and then
the DetailsView_DataBinding event, the DetailsView_ItemCreated event,
and the DetailsView_DataBound event all fire a second time. And then
the DataSource Unload event fires. The DataSource Selecting or
Selected event never fire.

When the ItemCreated event fires, the Visible attribute of the
ValidTimes row has been changed from false to true. This results in
the ValidTimes row being displayed, even though the "AlwasyValid" box
is checked.

Now, if I delete the ObjectDataSource, and substitute an SQLDataSource
that goes straight to the database table, this behavior does not
happen.

Can anyone explain to me why this is happening, why it doesn't happen
with an SQL DataSource, and what to do to make it behave "right" (or,
if by some definition, this is "right", explain that to me)? Thanks.
(I'll be happy to provide code on request. It's fairly straight
forward).

Thanks.
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top