The steps under "Collecting the Delivery Address", starting on page 239, do not work. Specifically the dropDownList is not showing up. I have followed all steps twice to reproduce the error. I have also changed the code to reflect the errata found on this site. Still broken.
I'm moving on to the next step of the wizard in the mean time, but can someone let me know if you've been able to get this to work?
Here's my code (of course if you have the book, you already have the code):
Code:
<td style="width: 100px" valign="top">
Area</td>
<td style="width: 100px" valign="top">
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Read" TypeName="StoredShoppingCart"
UpdateMethod="Update">
<UpdateParameters>
<asp:Parameter Name="DeliveryCharge" Type="Decimal" />
</UpdateParameters>
</asp:ObjectDataSource>
<asp:FormView ID="FormView1" runat="server" DefaultMode="Edit" DataSourceID="ObjectDataSource1">
<EditItemTemplate>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XML-Data/delivery-costs.xml">
</asp:XmlDataSource>
Deliver to
<asp:DropDownList ID="DropDownList" runat="server" AutoPostBack="True" DataSourceID="XmlDataSource1"
DataTextField="name" DataValueField="delivery-cost" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
SelectedValue='<%# Bind("DeliveryCharge") %>'>
</asp:DropDownList>
</EditItemTemplate>
</asp:FormView>
</td>
Here is the code-behind module:
Code:
Protected Sub ObjectDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles ObjectDataSource1.Updating
Dim ddl As DropDownList = DirectCast(FormView1.FindControl("DropDownList1"), DropDownList)
e.InputParameters("DeliveryCharge") = ddl.SelectedValue
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
FormView1.UpdateItem(False)
End Sub