我在 asp:wizard 中有两个列表框“在第 2 步中,在它之前和之后有一个步骤。通过使用一些代码,我将一些项目从第一个列表框带到第二个我想检查第二个的计数是否变了。我能做什么?
这是我的列表框代码
<asp:ListBox ID="registerCompCats" runat="server" CssClass="ListBox1"
ClientIDMode="Static" DataTextField="value" DataValueField="key" Rows="5"
size="5" style="width:135px; size:5px;" SelectionMode="Multiple" ></asp:ListBox>
<img id="addCat" src="images/buttons/btn_addCat.jpg" title="Add Category"/>
<asp:ListBox ID="registerCompAcats" runat="server" CssClass="ListBox2"
ClientIDMode="Static" DataTextField="value" DataValueField="key" Rows="5"
size="5" style="width:135px; size:5px; margin-top: 0px;" SelectionMode="Multiple"></asp:ListBox>
此代码运行良好并移动项目,但完成向导后第二个列表框为空。我可以做什么?
编辑
这是将数据从 listbox1 获取到 listbox2 的 java 脚本代码
$('#addCat').click(function () {
$(".ListBox1 > option:selected").appendTo(".ListBox2");
sortlist(".ListBox1 > option");
sortlist(".ListBox2 > option");
selectAll();
});
这就是检查项目并将它们添加到另一个列表的代码
for (int i = 0; i < rc.CategoriesIDs.Count; i++)
{
var foundcat = registerCompCats.Items.FindByValue(rc.CategoriesIDs[i].ToString());
if (foundcat != null)
{
registerCompAcats.Items.Add(foundcat);
registerCompCats.Items.Remove(foundcat);
}
}
如果您需要任何其他代码,我可以将其发布