C# 无法检索列表框项目值ASP.NET
我的C# 无法检索列表框项目值ASP.NET,c#,asp.net,listbox,C#,Asp.net,Listbox,我的ListFolderlistbox控件正在返回0项 我为测试设置了一个testLBlistbox控件,可以检索项目 下面是代码片段 前端: //Returned 0 <div class="tab-content"> <div id="sectionC" class="tab-pane fade in active"> <asp:ListBox runat="server" ID="listFolder" CssClass="fileHe
ListFolder
listbox控件正在返回0项
我为测试设置了一个testLB
listbox控件,可以检索项目
下面是代码片段
前端:
//Returned 0
<div class="tab-content">
<div id="sectionC" class="tab-pane fade in active">
<asp:ListBox runat="server" ID="listFolder" CssClass="fileHeight" Style="width: 100%;" SelectionMode="Single" ClientIDMode="Static" onclick="onListFolderClick(); ">
</asp:ListBox>
</div>
</div>
//Returned 1
<asp:ListBox ID="testLB" class="chosen" runat="server" Width="450px" Height="20px" SelectionMode="Single" ClientIDMode="Static">
<asp:ListItem>item1</asp:ListItem>
</asp:ListBox>
//Returned 0
Log.LogDebug("listFolder.Items.Count:" + listFolder.Items.Count, Location);
//Returned 1
Log.LogDebug("testLB.Items.Count: " + testLB.Items.Count, Location);
页面UI屏幕截图:
//Returned 0
<div class="tab-content">
<div id="sectionC" class="tab-pane fade in active">
<asp:ListBox runat="server" ID="listFolder" CssClass="fileHeight" Style="width: 100%;" SelectionMode="Single" ClientIDMode="Static" onclick="onListFolderClick(); ">
</asp:ListBox>
</div>
</div>
//Returned 1
<asp:ListBox ID="testLB" class="chosen" runat="server" Width="450px" Height="20px" SelectionMode="Single" ClientIDMode="Static">
<asp:ListItem>item1</asp:ListItem>
</asp:ListBox>
//Returned 0
Log.LogDebug("listFolder.Items.Count:" + listFolder.Items.Count, Location);
//Returned 1
Log.LogDebug("testLB.Items.Count: " + testLB.Items.Count, Location);
标题在左侧控件所有标题
上选择,并分别添加/删除到右侧控件选定标题
,列表文件夹
lb控件
最后,单击生成报告
按钮,将检索列表文件夹
lb控件中的所有值
我是否需要包括一个容器来存储物品,例如
,以便能够检索磅值
任何帮助都将不胜感激 首先您必须将
SelectionMode
更改为Multiple
<asp:ListBox runat="server" ID="listFolder" CssClass="fileHeight" Style="width: 100%;" SelectionMode="Multiple" ClientIDMode="Static" onclick="onListFolderClick(); ">
</asp:ListBox>
调用生成报告按钮上的SelectAllItems
:
<input type="submit" value="Generate Report" onsubmit="SelectAllItems()" />