当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·中奖了    »显示摘要«
    摘要: ms的鼠标,散分! ......
    摘要: 谢谢! ......


dropdownlist,很,在线等待

比如我的一个dropdownlist里面有很多的记录,我并不知道每条记录的索引号,我只知道里面有一条"李明"的记录,现在我想增加一个  
  button,点击button,让"李明"选中,该怎么办?很急,在线等待

NO.1   作者: pengweihua

this.DropDownList1.Items.FindByText("李明").Selected;

NO.2   作者: yqdeng

ok

NO.3   作者: zzhtd

笨办法  
  for(int   i=0;i<Dropdownlist1.items.count;i++)  
  {  
    if(dropdownlist1.items[i].text="李明")  
    {  
            dropdownlist1.selectindex:=i;  
            break;  
   
      }  
   
  }

NO.4   作者: timmy3310

DropDownList1.SelectedIndex   =   DropDownList1.Items.FindByText("李明").ItemIndex;

NO.5   作者: pengweihua

page_load:  
   
   
  if   (!IsPostBack)  
  {  
        DropDownList1.DataBind();  
  }

NO.6   作者: pengweihua

this.DropDownList1.Items.FindByText().Selected   =true;

NO.7   作者: pengweihua

<asp:ListItem   Value="0"   Selected="True">aaa</asp:ListItem>  
  去掉這Selected="True"  
  <asp:ListItem   Value="0"   >aaa</asp:ListItem>  
 

NO.8   作者: pengweihua

<asp:ListItem   Value="0"   Selected="True">aaa</asp:ListItem>  
  去掉這Selected="True"  
  <asp:ListItem   Value="0"   >aaa</asp:ListItem>  
   
   
  如果這也不行的話  
   
  請在page_load:加上這段代碼:  
   
  Response.Buffer   =   true;  
  Response.ExpiresAbsolute   =   DateTime.Now.AddDays(-1);  
  Response.Expires   =   0;  
  Response.CacheControl   =   "no-cache";  
   
   
   
  如果還是不行的話,沒辦法了  
  但是我經常是這樣寫的  
   
 

NO.9   作者: echoofice

ddlst_sex.Items[ddlst_sex.Items.IndexOf(ddlst_sex.Items.FindByText(“李明”))].Selected=true;  
 

NO.10   作者: timmy3310

Sorry:  
   
    DropDownList1.SelectedIndex   =   DropDownList1.Items.IndexOf(   DropDownList1.Items.FindByText("李明")   );

NO.11   作者: timmy3310

把你全部代码贴出来,改好了还给你

NO.12   作者: echoofice

<asp:ListItem   Value="0"   Selected="True">aaa</asp:ListItem>  
  去掉這Selected="True"  
   
  dp.Items[dp.Items.IndexOf(dp.Items.FindByText(“李明”))].Selected=true;  
 

NO.13   作者: pengweihua

改成這樣:  
   
   
  this.DropDownList1.SelectedIndex   =   this.DropDownList1.Items.IndexOf(this.DropDownList1.Items.FindByText("bbb"));  
   
  是可以的

NO.14   作者: lonwin

这样就可以搞定了  
  <1>令当前的被选定的ITEM取消选中     DROPDOWNLIST.SELECTEDITEM.SELECTED=FALSE  
  <2>然后选中你想要选中的ITEM             DROPDOWNLIST.ITEMS.FINDBYTEXT("李明").SELECTED=TRUE  
   
   
   
  试试吧!


    摘要: dj java decomplier只能一个一个地反编译,讨厌之级。 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE