c# - 如何将用户选择的值存储到由 SharePoint Web 部件呈现的 n DropDown 中?
问题描述
我是.NET* 和 **SharePoint的新手,我遇到了以下问题。
我正在开发一个Web 部件(到 Share Point 2013 中),它检索 n SharePoint 列表(这些列表的数量是可变的,它不是固定数字)并使用这些列表的内容来呈现 n DropDown(这些下拉列表的内容down 是相关 SharePoint 列表的内容)。
所以基本上进入我的 Web 部件的Page_Load()方法,我有这样的东西(它有效):
else if (mode != null && mode.Equals("scelta_campi_facoltativi_etichetta"))
{
SPList listaCampiOpzionaliEtichetta = contextWeb.Lists["ListaCampiOpzionaliEtichetta"];
String tipoDocumentiInternalName = listaCampiOpzionaliEtichetta.Fields["TipoDocumento"].InternalName;
Clausola c = null;
if (tipoDoc.Equals("docEntrata"))
{
c = new Clausola(Clausola.condizione.Eq, Clausola.tipoCampo.Choice, Clausola.CondizioneExtra.no, "Entrata", tipoDocumentiInternalName);
}
else if(tipoDoc.Equals("docUscita"))
{
c = new Clausola(Clausola.condizione.Eq, Clausola.tipoCampo.Choice, Clausola.CondizioneExtra.no, "Uscita", tipoDocumentiInternalName);
}
string q = Query.creaQueryWhere(c.query);
SPQuery queryQ = new SPQuery();
queryQ.Query = q;
SPListItemCollection etichetteCollection = listaCampiOpzionaliEtichetta.GetItems(queryQ);
Table table = new Table();
table.CellPadding = 2;
table.CellSpacing = 2;
table.Width = Unit.Percentage(100);
foreach (SPListItem item in etichetteCollection)
{
Debug.WriteLine("etichetta: " + item["NomeLista"] + " URL sito: " + item["UrlSito"]);
SPSite sitoEtichettaCorrente = new SPSite(item["UrlSito"].ToString()); // Top level website of the site collection
SPWeb currentWebSite = sitoEtichettaCorrente.OpenWeb();
//SPList eitchettaCorrenteList = currentWebSite.GetList(item["NomeLista"].ToString());
SPList eitchettaCorrenteList = currentWebSite.Lists[item["NomeLista"].ToString()];
String nomeColonna = item["NomeColonna"].ToString();
String codice = item["Codice"].ToString();
TableRow rigaCorrente = new TableRow();
TableCell cell1Corrente = new TableCell();
TableCell cell2Corrente = new TableCell();
cell1Corrente.Controls.Add(new LiteralControl((String)item["NomeLista"]));
DropDownList dropDownnEtichetta = new DropDownList();
for (int i = 0; i < eitchettaCorrenteList.Items.Count; i++)
{
dropDownnEtichetta.CssClass = "chosen-select";
dropDownnEtichetta.ClientIDMode = ClientIDMode.Static;
dropDownnEtichetta.ID = (String)item["NomeLista"];
string valoreDaMostrareInternalName = eitchettaCorrenteList.Fields[nomeColonna].InternalName;
string valoreDaStampareInternalName = eitchettaCorrenteList.Fields[codice].InternalName;
string valoreDaMostrare = eitchettaCorrenteList.Items[i].GetFormattedValue(valoreDaMostrareInternalName);
string valoreDaStampare = eitchettaCorrenteList.Items[i].GetFormattedValue(valoreDaStampareInternalName);
dropDownnEtichetta.Items.Add(new ListItem(valoreDaMostrare, valoreDaStampare));
cell2Corrente.Controls.Add(dropDownnEtichetta);
rigaCorrente.Controls.Add(cell1Corrente);
rigaCorrente.Controls.Add(cell2Corrente);
}
table.Controls.Add(rigaCorrente);
}
sceltaCampiEtichettaPanel.Controls.Add(table);
HtmlGenericControl buttondiv = new HtmlGenericControl("div");
Button bottoneConfermaCampiFacoltativiEtichetta = new Button();
bottoneConfermaCampiFacoltativiEtichetta.Text = "Conferma";
bottoneConfermaCampiFacoltativiEtichetta.CssClass = "shiny-blue";
//bottoneConfermaCampiFacoltativiEtichetta.OnClientClick = "return validatePwd();";
//bottoneConfermaCampiFacoltativiEtichetta.Click += ButtonSalva_Click;
buttondiv.Controls.Add(new LiteralControl("<br/>"));
buttondiv.Controls.Add(bottoneConfermaCampiFacoltativiEtichetta);
sceltaCampiEtichettaPanel.Controls.Add(buttondiv);
}
如您所见,我正在检索 SharePoint 列表的列表。我在每个列表上进行迭代,并使用相关当前列表的内容填充呈现的 DropDown 的竞争。
现在我的问题是:用户可以从这些DropDown中选择一个值。我想将用户选择的值(可能在类级别)存储到这些下拉列表中。
实施这项任务的明智策略是什么?
解决方案
推荐阅读
- regex - symfony 中有 Regex 约束的工作示例吗?
- python - 没有输出的alembic升级头
- ansible - 为什么重新安装ansible会导致“尝试将“/etc/ansible/hosts”读取为YAML”错误
- c# - Angular templateUrl:MVC 控制器功能
- vba - 代码在运行时不在调试模式下工作
- python - 导入模块的 Python 类型提示
- java - 如何使用 java 类而不是 xml 文件配置 logback 设置
- python - Keras 模型输入顺序
- python - 创建一个包含所有组合的列表(给出最大值)
- salesforce - 我正在尝试在 Apex 中创建一个触发器,这有助于在阶段更新时增加计数