我的dropdownlist的内容是数据表里取的,我想让dropdownlist定位到某个特定的item。用DataTextField或DataValueField匹配,我怎么知道匹配的项的index的值,请各位大哥指点一下,谢谢!

解决方案 »

  1.   

    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    Label1.Text=DropDownList1.SelectedItem.Value+":"+DropDownList1.SelectedItem.Text+"==="+DropDownList1.SelectedIndex;
    }==============
    DropDownList1.SelectedIndex:匹配的项的index的值
      

  2.   

    我的意思是,在我的dropdownlist里有ab,cd,ef,ae,.....,ee,ef等项,排列无规律,我想让我的dropdownlist选中其中的ee项,我应该怎么写程序?
      

  3.   

    我试着这样写DropDownList1.Items.FindByText("ee").Selected=true;
    可出现了如下错误:Object reference not set to an instance of an object.怎么办?
      

  4.   

    For I = 0 To seldec.Items.Count - 1
                    If seldec.Items(I).Text = myFunc.myIsNull(MyTab.Rows(0).Item("c_job_description")) Then
                        seldec.Items(I).Selected = True
                    End If
                Next