本文介绍了下拉列表的selectedindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if (DropDownList1.SelectedIndex >= 0 )
       {
           Literal2.Text  = DropDownList1.SelectedIndex .ToString ();
       }


我无法在if循环内的文字中显示选定的索引值,在上面的代码中,其将选定的索引值显示为0,任何替代方法都建议我.


i am not able to show a selected index value in a literal within the if loop, in the above code its showing the selected index value as 0, any alternative please suggest me.

推荐答案

if (DropDownList1.SelectedIndex != 0 )
       {
           Literal2.Text  = DropDownList1.SelectedIndex .ToString ();
       }


protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedIndex >= 0)
            lbl.Text = DropDownList1.SelectedIndex.ToString();
    }


这篇关于下拉列表的selectedindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:30