我正在尝试创建填充信息路径模板并将其上传到Sharepoint。我一直遵循以下说明https://www.codeproject.com/Articles/33228/Programmatically-create-a-browser-enabled-InfoPath
这是我生成的代码的一个示例
公共局部类myFields:
...
public partial class myFields
{
private General_Information general_InformationField;
...
public General_Information General_Information
{
get
{
return this.general_InformationField;
}
set
{
this.general_InformationField = value;
}
}
...
}
...
公共局部类General_Information
public partial class General_Information
{
private string wellField;
...
public string Well
{
get
{
return this.wellField;
}
set
{
this.wellField = value;
}
}
...
说明填充数据:
myFields fields = new myFields();
fields.Name = "Joe";
fields.Surname = "Blogs";
当我尝试按照网站中的示例进行操作时:
myFields fields = new myFields();
fields.General_Information.Well = "name";
我收到一条错误消息,说 myFields.General_Information。** get **返回null。
执行此操作的正确方法是什么?
答案 0 :(得分:0)
fields.General_Information.Well = "name";
应该在下面。您忘记实例化General_Information
类型,因此它为null。此外,不确定将它们设置为partial
类的需要。其实不应该。
fields.General_Information gi = new General_Information();
gi.Well = "name";