C# 将SharePoint BaseFieldControl BooleanField设置为true
我正在创建带有复选框控件的自定义SharePoint 2013编辑表单。我正在使用SharePoint BaseFieldControl对象C# 将SharePoint BaseFieldControl BooleanField设置为true,c#,sharepoint,sharepoint-2010,sharepoint-2013,C#,Sharepoint,Sharepoint 2010,Sharepoint 2013,我正在创建带有复选框控件的自定义SharePoint 2013编辑表单。我正在使用SharePoint BaseFieldControl对象 BaseFieldControl webControl = field.FieldRenderingControl; webControl.ID = string.Format("ctrl_{0}",field.InternalName); webControl.FieldName = field.Title;this.Controls.Add(we
BaseFieldControl webControl = field.FieldRenderingControl;
webControl.ID = string.Format("ctrl_{0}",field.InternalName);
webControl.FieldName = field.Title;this.Controls.Add(webControl);
webControl.ControlMode = SPControlMode.edit;
SPQuery camlQuery = new SPQuery();
camlQuery.ViewXml = String.Format("<View><Query><Where><Geq><FieldRef Name='ID'/>" +
<Type='Number'>{0}</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>", id);
SPListItemCollection items = SafeguardingList.GetItems(camlQuery);
SPListItem item = items[0];
if (items.Count > 0 && !string.IsNullOrEmpty(item[field.Title].ToString()))
{
SPFieldType fieldType = field.Type;
switch (fieldType)
{
case SPFieldType.Boolean:
this.Controls.Add(webControl);
break;
}
}
BaseFieldControl webControl=field.FieldRenderingControl;
webControl.ID=string.Format(“ctrl{0}”,field.InternalName);
webControl.FieldName=字段.标题;this.Controls.Add(网络控制);
webControl.ControlMode=SPControlMode.edit;
SPQuery camlQuery=新建SPQuery();
camlQuery.ViewXml=String.Format(“”)+
{0}100“,id);
SPListItemCollection items=SafeguardingList.GetItems(camlQuery);
SPListItem=items[0];
if(items.Count>0&&!string.IsNullOrEmpty(item[field.Title].ToString())
{
SPFieldType fieldType=字段类型;
开关(现场型)
{
案例SPFieldType.Boolean:
this.Controls.Add(网络控制);
打破
}
}
我试图在呈现页面时将复选框控件设置为“True”
<input name="name$ctl00$BooleanField" id="name_ctl00_BooleanField" type="checkbox"/>
我试过:
webControl.ItemFieldValue=“1”
webControl.Field.DefaultValue=“1”
这似乎不起作用
提前谢谢你