488
צפיות
צפיות
1
תשובות
תשובות
listBox
בעבודה עם List box ב- asp.net
#c
אני לא מצליחה לגרום לפריט ברשימה להיות מסומן (selected).
אני מנסה להעביר פריט מרשימה לרשימה בעת לחיצה על כפתור ולא קורה כלום, אחרי בדיקה, הבנתי שאין פריט מסומן.
string strSelection;
if (lbExist.SelectedItem != null)
{
strSelection = lbExist.SelectedItem.Text;
if (lbWanted.Items.FindByText(strSelection)== null )
{
lbWanted.Items.Add(strSelection);
lbWanted.SelectedIndex =0;
strSelection = null;
}
}
רשימה ראשונה
lblExist
רשימה שניה
lblWanted
תודה
1 תשובות
ישרי קוד לשמאל
string strSelection;
if (lbExist.SelectedIndex > -1){
strSelection = lbExist.SelectedItem.Text;
if (lbWanted.Items.FindByText(strSelection)== null ){
lbWanted.Items.Add(strSelection);
lbWanted.SelectedIndex =0;
strSelection = null;
}
}
מצורפת דוגמא, שאני ל aspx, כמובן.