SelectedIndexChanged方法不起作用 [英] SelectedIndexChanged method not working

查看:147
本文介绍了SelectedIndexChanged方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void ClassDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
            if (ClassDropDownList.SelectedValue.Selected)
            {                 
            string myXMLfile = Server.MapPath("~/OrgList.xml");
            DataSet NAME_DATASET = new DataSet();
            NAME_DATASET.ReadXml(myXMLfile);
            NameDropDownList.DataSource = NAME_DATASET;
            NameDropDownList.DataTextField = "NAME";
            NameDropDownList.DataValueField = "ID";
            NameDropDownList.DataBind();
            }
}



我已经有一个类下拉列表.当在类下拉列表中选择一个项目时,我希望填充名称下拉列表.为什么不人口稠密.



I already have a class dropdownlist .when an item is selected in the class dropdown list i want the name dropdownlist to be populated. why is not popuating . what else should be done can i get the c# code please.

推荐答案

此变量的名称是否怪异ClassDropDownList(哇!给出了某种类型的变量名一个以"Class"开头的名字,您可能将应用程序命名为"Application * .exe",而您的项目命名为"Project * .csproj",不是吗? >?如果是这样,则您键入的代码与您实际尝试运行的代码不同,或者您说的有关观察的说法不正确.这是因为属性SelectedValue的类型为System.String,因此它不能具有名为Selected的成员,因此该代码将无法编译.

提出问题之前,请记住,说出真相和说出真相是好事.

—SA
Is this variable with weird name ClassDropDownList (Wow! a variable name of some type is given a name started with "Class". You probably name applications "Application*.exe" and your projects "Project*.csproj", don''t you? :-))… so, is this variable really of the type System.Web.UI.WebControls.DropDownList? If so, you either typed not the same code you really try run, or what you say about your observation is not true. This is because the property SelectedValue is of the type System.String, so it cannot have a member called Selected, so this code would not compile.

Before asking questions, keep in mind that it''s good to say truth and nothing but truth.

—SA


这篇关于SelectedIndexChanged方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆