作者leicheong (睡魔)
看板Programming
标题Re: asp.net 2.0 vb语法与listbox的疑问
时间Wed May 9 12:20:10 2007
※ 引述《[email protected] (帮我投票吧)》之铭言:
: 但倘若Value的值与text不同,那执行时就会变慢
: Button3执行时,无法移除listbox1资料
: 而Button4执行时,速度奇慢
: 可是,若value与text相同,
: 若我写成以下的样式就可以
: <asp:ListItem Value="A">A</asp:ListItem>
: 那就不会有这问题
: 请问,我的网页哪里需要做微调的呢
: 网页可由http://rapidshare.com/files/30133320/list2.zip下载
: 谢谢
这问题建议先详细阅读MSDN Library中有关ListItemCollection.Remove()
一节. 当中有说明当parameter是string时是怎样implement的.
再参考当ListItem的constructor只有一个parameter时是甚麽意思.
简单来说, 当你的ListItem的Text和Value不同时, 增加时请尽量用
new ListItem(text, value)而不是用new ListItem(value)
而移除时直接送ListBox1.Items.Remove(ListBox1.SelectedItem),
ListBox1.Items.Remove(ListBox1.Items(0))这样就可以了, 不要
ListBox1.Items.Remove(ListBox1.SelectedItem.Value),
ListBox1.Items.Remove(ListBox1.Items(0).Value)
最後, 像我以前强调了无数次的, 这些动作(在两个select element
中传递item而中间没需要另作处理时)用javascript在client side
进行比较好.
P.S.: 又发了一篇「站内」文... 因此砍了再发过.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 202.134.126.84