Bind Asp Controls to ObjectDataSource.Select

G

Guest

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().CurrentOrderTrackingId;
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.ShoppingCartSummaryDo"
SelectMethod="GetSummary" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top