On 17 Nov, 01:37, B. Chernick wrote:
Quote:
Originally Posted by
Sorry, actually no. If I move the code into the DetailView's DataBinding
event (or the screen's), the code fails entirely because it can't find the
ddl. Hasn't been rendered yet.
Milosz is right about the timing of the code causing the exception. In
insert mode, there is no attempt to automatically bind the selected
value of the ddl control to a field value because it's a new record,
whereas in Edit mode it tries to bind the selected value to the
current value of the field.
To get round this you'll have to delete the databinding between the
ddl and the datasource (in the edit mode template) and set the
selected value manually in code immediately after the code you have
already written. In the DataBound event, you can differentiate
betweeen the two modes using DetailsView1.CurrentMode() and make the
code for setting the ddl selected value conditonal upon that.
You'll also need to handle the update manually for the respective
datafield as well in the Updating event.
HTHThank you Milosz and Phil.
Out of town for the holiday but I continue this as soon as I get home Friday.
"Phil H" wrote:
Quote:
Originally Posted by
Hi
>
On 17 Nov, 01:37, B. Chernick wrote:
Quote:
Originally Posted by
Sorry, actually no. If I move the code into the DetailView's DataBinding
event (or the screen's), the code fails entirely because it can't find the
ddl. Hasn't been rendered yet.
>
Milosz is right about the timing of the code causing the exception. In
insert mode, there is no attempt to automatically bind the selected
value of the ddl control to a field value because it's a new record,
whereas in Edit mode it tries to bind the selected value to the
current value of the field.
>
To get round this you'll have to delete the databinding between the
ddl and the datasource (in the edit mode template) and set the
selected value manually in code immediately after the code you have
already written. In the DataBound event, you can differentiate
betweeen the two modes using DetailsView1.CurrentMode() and make the
code for setting the ddl selected value conditonal upon that.
>
You'll also need to handle the update manually for the respective
datafield as well in the Updating event.
>
HTH
>
0 comments:
Post a Comment