首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请教一个dropdownlist的有关问题

2012-01-23 
请问一个dropdownlist的问题?按视频教程做练习publicpartialclassWelcom:System.Web.UI.Page{publicclassc

请问一个dropdownlist的问题?
按视频教程做练习
public   partial   class   Welcom   :   System.Web.UI.Page  
{
        public   class   car
        {
                private   string   color;
                private   int   chelun   =   4;
                public   string   Color
                {
                        get
                        {
                                return   color;
                        }
                        set
                        {
                                color   =   value;
                        }
                }

                public   int   Chelun
                {
                        get
                        {
                                return   chelun;
                        }
                }

                public   string   getinfo(string   a,   string   b)
                {
                        string   c   =   " ";
                        switch   (a)
                        {
                                case   "#red ":
                                        c   +=   "你的车是红色的 <br> 车轮 "   +   b;
                                        break;
                                case   "#black ":
                                        c   +=   "你的车是黑色的 <br> 车轮 "   +   b;
                                        break;



                        }
                        return   c;
                }
        }

                 
        protected   void   DropDownList1_SelectedIndexChanged(object   sender,   EventArgs   e)
        {
                car   onecar   =   new   car();
                onecar.Color   =   DropDownList1.SelectedValue.ToString();
                string   a   =   onecar.Color.ToString();
                string   b   =   onecar.Chelun.ToString();
                string   c   =   onecar.getinfo(a,   b);
                Response.Write(c);


        }
}


为何当我执行时选择dropdownlist   框中的选项,没有什么动作发生,
#red在dropdownlist框中对应的是text还是value,  
请大家帮忙,多谢!
请大家帮忙,多谢!

[解决办法]
<asp:DropDownList AutoPostBack = true ...
[解决办法]
#red在dropdownlist框中对应的是text还是value,

======

没有看到任何绑定/添加数据 DropwDownList 代码
[解决办法]
照你的程序看,#red应该是value。将dropdownlist的AutoPostBack 设置为true
[解决办法]
AutoPostBack = true 这个可能性很大
[解决办法]
AutoPostBack = true


AutoPostBack
[解决办法]
LS正解
[解决办法]
AutoPostBack = true

热点排行