I have a wizard with various ASP Controls (TextBox/ Dropdown etc...) on the
Wizard.
The last Step before user clicks the finish button displays a DetailsView
listing all the values that the user selected through the wizard.
I have a method on my Page called GetSummary, which returns an
SummaryObject, this was populated by unbinding the controls onto the object
and then Binding this object to the DetailsView within the OnActivate event.
What I would prefer, is to you set the DataSourceId property of the
DetailsView object and use the SelectMethod attribute but this does not work
because the Page state is not initialized (eg. txtPoNumber is null).
Can I do what I want to do ?
// Currently Works as Follows
#region wiz1_OnActivateStep4 (OnActivate='wiz1_OnActivateStep4')
protected void wiz1_OnActivateStep4(Object sender, EventArgs e)
{
dvSummary.DataSource = new CheckOutPageSummaryDo[] { GetSummary() };
dvSummary.DataBind();
}
#endregion
#region GetSummary
private CheckOutPageSummaryDo GetSummary()
{
CheckOutPageSummaryDo result = new CheckOutPageSummaryDo();
//result.PaymentMethod =
//
((DropDownList)wiz1.WizardSteps[0].FindControl("ddlPaymentMethod")).SelectedValue
result.PaymentMethod = ddlPaymentMethod.SelectedValue;
result.PoNumber = txtPoNumber.Text;
if (ddlPaymentMethod.SelectedValue.IndexOf("Moneytech ") == -1)
{
result.CreditCardNo = txtCreditCardNo.Text;
result.Expiry = txtExpiry.Text;
}
else
{
result.PreAuthId = txtPreAuthID.Text;
}
result.OrderTrackingId =
DistiBo.GetCurrentOrderView().CurrentOrderTracking Id;
result.TotalValue = DistiBo.GetCurrentOrderView().CartTotalValue;
result.TotalGst = DistiBo.GetCurrentOrderView().CartTotalGst;
return result;
}
#endregion
// This is what I want
<asp:DetailsView ID='dvSummary' runat='server'
DefaultMode="ReadOnly" AutoGenerateRows="false" DataSourceID='odsGetSummary' >
<Fields>
<asp:BoundField DataField='PaymentMethod'
HeaderText='Payment Method' />
<asp:BoundField DataField='PoNumber' HeaderText='Po #' />
<asp:BoundField DataField='CreditCardNo'
HeaderText='Credit Card #' NullDisplayText='---'/>
<asp:BoundField DataField='Expiry' HeaderText='Expiry'
NullDisplayText='---'/>
<asp:BoundField DataField='PreAuthID' HeaderText='PreAuth
ID' />
<asp:BoundField DataField='OrderTrackingId'
HeaderText='Order Tracking Id' />
<asp:BoundField DataField='TotalValue' HeaderText='Total
Value' DataFormatString='{0:c}' />
<asp:BoundField DataField='TotalGst' HeaderText='Total
Gst' DataFormatString='{0:c}' />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="odsGetSummary" runat="server"
TypeName="Wb.Ui.Reseller.CheckOut.CheckOutPage"
DataObjectTypeName="Wb.Bo.Disti.Data.ShoppingCartS ummaryDo"
SelectMethod="GetSummary" />