求指教DropDownList的
DropDownList1.SelectedIndex
DropDownList1.SelectedValue
DropDownList1.SelectedItem
各是什么东西?怎么用?

解决方案 »

  1.   

    DropDownList1.SelectedIndex  //选择项索引
    DropDownList1.SelectedValue  //选择项的值
    DropDownList1.SelectedItem   //获得选择的项你试试都得到什么不就知道了
      

  2.   

    DropDownList1.SelectedIndex //选择项索引
    DropDownList1.SelectedValue //选择项的值
    DropDownList1.SelectedItem //获得选择的项
      

  3.   

    好像SelectedValue和SelectedItem选出来的东西都是一样的!
      

  4.   

    自己用response.write输出下就明白了
      

  5.   

    DropDownList1.SelectedIndex   选中项的索引值
    DropDownList1.SelectedValue   选中项的Value属性
    DropDownList1.SelectedItem    选中的项,一般包含Text和Value2个属性
      

  6.   

    这种东西可以查查MSDN啊。这些。
      

  7.   

    DropDownList1.SelectedIndex //选择项的下标
    DropDownList1.SelectedValue //选择项的value值
    DropDownList1.SelectedItem //选择项的text值
      

  8.   

    假设有这样一个DropdownList:
    <asp:DropDownListID="d1" runat="server">
        <asp:ListItemText="AAAA" Value="a"></asp:ListItem>
        <asp:ListItemText="BBBB" Value="b"></asp:ListItem>
        <asp:ListItemText="CCCC" Value="c"></asp:ListItem>
    </asp:DropDownList>DropDownList1.SelectedIndex的用法:
    d1.Items[di.SelectedIndex]等于当前的选中项,SelectedIndex意为当前选中的索引,它可能的值为{0,1,2},d1.Items[0]则表示选中项是"AAAA"DropDownList1.SelectedValue的用法:
    拿到当前选中项的Value值,如果选中项是"AAAA",那么d1.SelectedValue等于"a"。DropDownList1.SelectedItem的用法:
    拿到当前的选中项,如果选中项为"AAAA",那么d1.SelectedItem.Text就是"AAAA",d1.SelectedItem.Value就是"a"。d1.SelectedItem.Value = d1.SelectedValue = d1.Items[d1.SelectedIndex].Value
      

  9.   

    DropDownList1.SelectedValue和DropDownList1.SelectedItem有一点不同的是在绑定到数据库时,DropDownList1.SelectedValue读取的值是数据库里面的值。而DropDownList1.SelectedItem读取的是文本的值。比如网页上文本显示值是男,数据库里面男的表示是用1表示的,这时候用DropDownList1.SelectedValue读出的值就是1.呵呵,希望能够帮助到你!
      

  10.   

    要了解怎么用其实很简单,到后台cs代码中,断点调试,通过vs环境的代码联想功能及属性的相关注释,可以摸清楚DropDownList的一些属性与方法的用法。