问题描述
我使用了以下代码:
I used this code:
protected void Button1_Click(object sender, EventArgs e)
{
using (SPSite site = new SPSite(Convert.ToString(SPContext.Current.Web.Url)))
{
using (SPWeb web = site.OpenWeb())
{
using (SPWeb web1 = site.OpenWeb("Sales"))
{
web.AllowUnsafeUpdates = true;
SPList list1 = web.Lists["AviList1"];
SPList list2 = web1.Lists["AviList2"];
if (list1 != null)
{
string fieldXML = "<field displayname="MyLookUpColumn" type="Lookup" required="FALSE" list="" list1.id="" webid="" web.id="" name="MylookUpColumn" showfield="" />";
list2.Fields.AddFieldAsXml(fieldXML, true, SPAddFieldOptions.AddFieldToDefaultView);
}
}
}
}
}
AviList1位于rootsite上,有两列:Name列(单行文本类型)和Country列(choice类型).
当我运行此代码时,列''MyLookUpColumn''
被添加到AviList2中,其值是我在AviLIst1的国家/地区列中输入的值.但是问题是当我在AviLIst2中进行输入时.
发生了什么,而不是在AviList2的MyLookUpColumn
列中保存值,而是在AviList2的该列中保存了#err.
请尽快解决我的问题.请发送代码.谢谢.
请仔细阅读我的整个问题&然后请回复.
非常感谢.......
AviList1 is on rootsite and has two columns: Name column which is of type single line text and Country column which of type choice.
When I run this code a column ''MyLookUpColumn''
is added in AviList2 with values that I have made entries in Country column of AviLIst1.But problem is that when I make entries in AviLIst2.
What is happening, instead of saving value in MyLookUpColumn
column of AviList2,it is saving #err in that column of AviList2.
Please solve my problem as soon as possible.Plz send the code.Thanks in advance.
Please read my whole problem carefully & then please reply.
Thanks a lot................
推荐答案
这篇关于跨Web查找列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!