我创建了一个移动单据,列表点击进入表单呈现内容(可编辑),但是在进入表单后单据体始终加载不出,下面是代码
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//如果传入内码,加载完整数据包
var srcBusinessInfo = SourceBillMetadata.BusinessInfo;
var openParameter = (this.View.OpenParameter as MobileOpenParameter);
if (openParameter != null && openParameter.PkValue != null)
{
this.SourceObject = BusinessDataServiceHelper.LoadSingle(this.Context, openParameter.PkValue, srcBusinessInfo, null);
var nextsunday = this.SourceObject["F_gzjh_planstarttime"];
var nextSaturday = this.SourceObject["F_gzjh_planendtime1"];
this.Model.SetValue("F_gzjh_planstarttime", nextsunday);
this.Model.SetValue("F_gzjh_planendtime1", nextSaturday);
// 单据体(单据体行集合属性本身只读,可以通过单据体集合提供的方法,添加行、删除行)
DynamicObjectCollection entityRows = this.SourceObject["FEntity"] as DynamicObjectCollection;//
// DynamicObjectCollection dy = this.Model.DataObject["FMobileListViewEntity"] as DynamicObjectCollection;
int i = 0;
this.Model.BeginIniti();
int rowIndex = this.Model.GetEntryRowCount("FMobileListViewEntity");
foreach (var entityRow in entityRows)
{
String projectName = Convert.ToString(entityRow["F_gzjh_jbxx_xmname"]);
String projectInfo = Convert.ToString(entityRow["F_GZJH_JBXX_TASKINFO"]);
String startDate = Convert.ToString(entityRow["F_gzjh_jbxx_time"]);
String endDate = Convert.ToString(entityRow["F_q_Date3"]);
String workDays = Convert.ToString(entityRow["F_gzjh_jbxx_plantime"]);
this.View.Model.CreateNewEntryRow("FMobileListViewEntity");
this.Model.SetValue("F_q_Text", projectName, i );
this.Model.SetValue("F_q_Text1", projectInfo, i );
this.Model.SetValue("F_q_Date", startDate, i );
this.Model.SetValue("F_q_Date1", endDate, i );
this.Model.SetValue("F_q_Decimal", workDays, i );
i++;
}
this.Model.EndIniti();
this.View.UpdateView("FMobileListViewEntity");
this.View.UpdateView("F_gzjh_planstarttime");
this.View.UpdateView("F_gzjh_planendtime1");
this.Model.DataChanged = true;
}
调试进入发现OnLoad方法全部走完了,才发生报错
未将对象引用到实例
这是什么原因,求大神帮忙看看
推荐阅读