开发者

how to get the items in listbox one by one in asp.net using c#

开发者 https://www.devze.com 2022-12-29 13:05 出处:网络
how to get the items in listbox one by one e.g : in 开发者_运维问答my listbox i have items (roll no\'s)

how to get the items in listbox one by one

e.g : in 开发者_运维问答my listbox i have items (roll no's)

s1 s2 s3 s4 s5 etc...

how to get the items on by one


if you need to pick out specific items you can do following (nul-based) :

string item = lstItems.Items[index].toString();

if you need all items in a list, you can use David's method, or much shorter, use this

var myList = lbMyListBox.Items.Cast<String>().ToList();


 IList<string> items = new List<string>();

 foreach(ListItem item in myListBox.Items)
 {
     items.Add(item.Text);
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消