私は10のリストボックスのすべての10のリストボックスのための10のリストボックスを持っています同じ機能がいくつかのボタンを使用しています私はリストボックスのデータをグリッドに追加したいのですか?コードは、私は誰もが言うことができます0を与えlistbox.items.count保存しようとすると、HTMLの入力ボタンの問題を使用して、リストボックスの間で項目を移動するためのコード上でJavaScriptを試してみましたポストバックが発生するJavaScriptリストボックスの項目がasp.netで失われた
function MoveItem(ctrlSource, ctrlTarget) {
var Source = document.getElementById(ctrlSource);
var Target = document.getElementById(ctrlTarget);
if ((Source != null) && (Target != null)) {
while (Source.options.selectedIndex >= 0) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = Source.options[Source.options.selectedIndex].text;
newOption.value = Source.options[Source.options.selectedIndex].value;
Target.options[Target.length] = newOption; //Append the item in Target
Source.remove(Source.options.selectedIndex); //Remove the item from Source
}
}
}の下に表示します私はなぜこれが起きているのか、ポストバックが発生したときリストボックス項目が失われました。
jQueryを使用してリストボックス間でアイテムを転送することができます:http://dpatri.com/technology/jquery/move-list-box-items-from-left-to-right-using-jquery/ –