Asp.Net ListView LinqDataSource Declaratively Bind Child Objects

361 views Asked by At

I have a ListView with a LinqDataSource. In the Edit Template we need to edit both the primary object and a related (1 to 1) child object.

In the past I have used code for all of this and manually handled Updates, but I am wondering whether there is a declarative way to get the LinqDataSource to handle it for me.

More specifically:

  1. Is there a way to declaratively bind the child object to our edit inputs and if so what is the sytax?

  2. Is there any way to declaratively bind a LinqDataSource item ("MyLinqObject") to the selected Item/Value of a DropDownList ?

1

There are 1 answers

0
Serexx On BEST ANSWER

Got this one myself. Child object is simply <%# Bind("MyChildObjectTypeName.MyChildObjectPropertyName") %>'>.

The DropDown question came up because for some reason Intellisense doesn't show a "SelectedValue" property in the DropDownList declaration markup.

Of course, simply adding it anyway works as it should.

SelectedValue='<%# Bind("PropertyName") %>'>