Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我可以向.NET ListItem呈现对象添加第三个字段吗?_C#_.net_Sharepoint_Sharepoint 2013_Selectlistitem - Fatal编程技术网

C# 我可以向.NET ListItem呈现对象添加第三个字段吗?

C# 我可以向.NET ListItem呈现对象添加第三个字段吗?,c#,.net,sharepoint,sharepoint-2013,selectlistitem,C#,.net,Sharepoint,Sharepoint 2013,Selectlistitem,我不太喜欢.NET和SharePoint,我对将Web部件纳入SharePoint 2013项目有以下疑问 在我的web部件中,我有这样一个下拉列表: DropDownList dropDownnEtichetta = new DropDownList(); 然后,我通过以下方式将一些项目添加到此DropDownList: for (int i = 0; i < etichettaCorrenteList.Items.Count; i++) { dropDownnEtichett

我不太喜欢.NETSharePoint,我对将Web部件纳入SharePoint 2013项目有以下疑问

在我的web部件中,我有这样一个下拉列表:

DropDownList dropDownnEtichetta = new DropDownList();
然后,我通过以下方式将一些项目添加到此DropDownList:

for (int i = 0; i < etichettaCorrenteList.Items.Count; i++)
{
    dropDownnEtichetta.Items.Add(new ListItem(valoreDaMostrare, valoreId));
}
ListItem currentItem = new ListItem(valoreDaMostrare, valoreId);
currentItem.Attributes.Add("valoreDaStampare", valoreDaStampare);

dropDownnEtichetta.Items.Add(currentItem);
for(int i=0;i
它工作正常,正如您可以看到的那样,列表项通过下拉列表中显示的文本和值填充

我想知道是否可以在此列表项中添加第三个信息。万一我能做什么

https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.listitem.-ctor?view=netframework-4.7.2 
显示ListItem没有接受三个字符串参数的构造函数。它只是

ListItem()  
ListItem(String)    
ListItem(String, String)    
ListItem(String, String, Boolean)
这些构造器


出于ypur目的,您可以扩展ListItem类。

我自己用以下方法解决:

for (int i = 0; i < etichettaCorrenteList.Items.Count; i++)
{
    dropDownnEtichetta.Items.Add(new ListItem(valoreDaMostrare, valoreId));
}
ListItem currentItem = new ListItem(valoreDaMostrare, valoreId);
currentItem.Attributes.Add("valoreDaStampare", valoreDaStampare);

dropDownnEtichetta.Items.Add(currentItem);