动态设置asp:dropdown的selectedIndex

问题描述

| 我正在选择要显示的文字,例如\“ selected \”,\“ unselected \” 我想动态设置为“ selected”
dropdown.selectedIndex = dropdown.Items.FindByText(\"selected\");
怎么设置?请指导     

解决方法

        你快到了
dropdown.Items.FindByText(\"selected\").Selected = true;
编辑 要通过javascript实现此目的,您将必须遍历下拉菜单中的
option
元素。像这样的东西
function setIndexByText() 
{
   drp = document.myform.selectcontrol; //this would be your dropdown
   str = \"selected\";
   for (indx=0; indx < drp.options.length; indx++) 
   {
       if (drp.options[indx].text == str) 
       {
          drp.selectedIndex = indx;
       }
   }
}
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...