ASPX列表框自动选择 [英] ASPX Listbox AutoSelect

查看:122
本文介绍了ASPX列表框自动选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我需要知道ASPX中是否有一种方法可以自动选择列表框中的第一个值,我已经尝试使用

Hello,

I need to know if there is a way in ASPX to auto select the first value in listbox,i''ve already tried to use

ListBox_servidores.SelectedIndex = 0;
ListBox_servidores.Items[0].Selected = true;


但是它不起作用,第一个代码选择了列表框中的第一个项目,但是与此同时,当我尝试在另一段代码中使用选定的项目时,它似乎没有被选择.
第二个代码只是返回一个错误:


but its not working, the first code selects the first item in the listbox, but at the same time when i try to use the selected item in another piece of code it looks like it is not selected.
The second code just returns an error :

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index



问候
谢谢



Regards
Thank You

推荐答案

OP和Ed用评论解决了这个问题!

将其发布以将其从未答复的列表中弹出.
OP and Ed resolved the issue with comments!

Posting this to pop this one out of unanswered list.


这篇关于ASPX列表框自动选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆