I am having a hard time loading a data into my FormView elements. Basically,
My FormView is in insert mode. It looks like this. Before this page is loaded, I have Session["PO Number"] = "PO123". If you look at the bottom of Initialize(),
I have the following:
if (Session["PO Number"] != null){
FormView1.DefaultMode =
FormViewMode.Edit; //FormView1.DataBind();}
So, my objective is to after the UI elements are initialized with items, I want to load a business obejct and have the values set automatically, but it's not working. In my aspx file, I have
<%# Bind("DateString") %>
for each UI element.
Please help.
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack){
}
else{
Initialize();
}
}
protected void Initialize(){
// Vendor DropDownList ddlVendor = (DropDownList)FormView1.FindControl("ddlVendor"); Companies oCompanies = Intel.SystemEngineering.Procure.Companies.GetCompanyList(2); Vendors oVendors = Intel.SystemEngineering.Procure.Vendors.GetVendors(0); foreach (Company oCompany in oCompanies){
foreach (Vendor oVendor in oVendors){
if (oCompany.ID == oVendor.CompanyID)ddlVendor.Items.Add(
new ListItem(oCompany.ShortName, oVendor.ID.ToString()));}
}
// Bill To and Ship To DropDownList ddlBillTo = (DropDownList)FormView1.FindControl("ddlBillTo"); DropDownList ddlShipTo = (DropDownList)FormView1.FindControl("ddlShipTo");oCompanies = Intel.SystemEngineering.Procure.
Companies.GetCompanyList(1); // 1 is a company type foreach (Company oCompany in oCompanies){
ddlBillTo.Items.Add(
new ListItem(oCompany.ShortName, oCompany.ID.ToString()));ddlShipTo.Items.Add(
new ListItem(oCompany.ShortName, oCompany.ID.ToString()));}
// Status DropDownList ddlStatus = (DropDownList) FormView1.FindControl("ddlStatus"); PurchaseOrderStatuses oStatuses = Intel.SystemEngineering.Procure.PurchaseOrderStatuses.GetPurchaseOrderStatuses(); foreach (PurchaseOrderStatus oStatus in oStatuses)ddlStatus.Items.Add(
new ListItem(oStatus.Name, oStatus.ID.ToString())); //CslaDataSource1.SelectObject += new EventHandler<Csla.Web.SelectObjectArgs>(OnSelect); //CslaDataSource1. if (Session["PO Number"] != null){
FormView1.DefaultMode =
FormViewMode.Edit; //FormView1.DataBind();}
}
protected void OnSelect(object sender, Csla.Web.SelectObjectArgs e){
e.BusinessObject =
PurchaseOrder.GetPurchaseOrder("PO123"); //FormView1.DataBind(); //e.BusinessObject. //PurchaseOrder oPO = PurchaseOrder.GetPurchaseOrder("PO123"); //Csla.Data.DataMapper.Map(e.Values, oPO); //e.RowsAffected = 1; //oPO.Save(); //Session["PO Number"] = oPO.Number; //Response.Redirect("LineItem.aspx", true);}
Copyright (c) Marimer LLC