Well, I was thinking I'd get an answer to this question and understand
what I was in for before changing too much of the code, but I decided
to bite the bullet and just try it. I was pleasantly surprised to find
that when changes are made to a foreign key field using a dropdown list
in the edititem template of my formview control, they are, in fact,
reflected in the itemview template textbox. That tells me that the data
is re-queried when the changes are saved. This is a good thing in that
respect.
The downside, for my application anyway, is that also means that child
records that are displayed in a grid on the same page will also be
written to the database upon saving. How might I roll back the addition
of new child records in the event the user cancels the edit operation
on the parent?
For instance, if a user clicks the New button in my formview control to
add a new parent record and in the process adds a couple of child
records, then decides to cancel the insert process on the parent, what
happens with the newly-created child records? How can I avoid those
records being written to the database until the parent record is saved?
I have another post dedicated to this question. Answers may be more
appropriately directed there.
Thanks!
Rich
Richard Carpenter wrote:
Well, I had considered that, but does that cause a problem in, for
example, a formview control? If I bind a textbox to the CompanyName in
the itemview template and a dropdown list control to the CompanyID in
the edit and insert templates, what will I need to do to ensure that
the itemview template displays the correct value after an edit or
insert? Anything?
Rich
Göran Andersson wrote:
Make a join in the query when you are fetching the data.
Example:
select a.this, a.that, c.CompanyName
from Article a
inner join Company c on c.CompanyId = a.CompanyId
Richard Carpenter wrote:
I understand how to use a dropdown list control to display the
associated description value for a foreign key in a parent rather than
the key itself, but I don't like having to disable the control when I
want to prevent editing (simply displaying in the display template ofa
datalist or detailview control, for example). I've not been able to
find a way to edit the disabled color of the dropdown list, so it
appears very washed out - just not a good look and doesn't make much
sense to the user.
>
Is there a way to bind a text box to the description field in a lookup
table? If I'm showing a list of orders, I really don't want to display
the surrogate key value to denote the customer. I would rather display
the customer's name from the Customers table.
Rich
>