我有两种类型的查找列表字段。当用户更改第一个字段时,如何动态更改第二个字段的值?这是我的绑定代码(用于编辑项目表单的Web部件代码):
protected override void OnPreRender(EventArgs e)
{
SPFormContext fc = SPContext.Current.FormContext;
foreach (BaseFieldControl bfc in fc.FieldControlCollection)
{
if (bfc.FieldName == "type12")
{
DropDownList ddl = FindControlRecursive(bfc, "Lookup") as DropDownList;
if (ddl != null)
ddl.Attributes.Add("onchange", "javascript:alert('Test')");
}
}
}
public static Control FindControlRecursive(Control root, string id)
{
if (root.ID == id)
return root;
foreach (Control c in root.Controls)
{
Control t = FindControlRecursive(c, id);
if (t != null)
return t;
}
return null;
}