【发布时间】:2016-02-17 04:39:40
【问题描述】:
当我从此下拉列表 (DDL1) 中选择任何项目时,我有一个下拉列表 (DDL1),导致创建另一个下拉列表 (DDL2),其中包含一些项目。当我从 DDL1 中选择其他项目时,项目将更改在 DDL2 中,这发生在 DDL1 中选择的每个不同项目上。
当我从 DDL2 中选择一个项目时,必须显示标签内容,最初我正在制作标签 invisibe 并且在代码中我将可见性更改为 true 并向其添加内容。但是当我从 DDL2 中选择一个项目时,标签内容不显示。
这是我的代码
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "Abe Books")
{
DropDownSeller.Visible = true;
lnkUsdBooks.Visible = true;
lnkUsdBooks.Text = "usedbooks@abe.com";
lnkUsdBooks.NavigateUrl = "mailto:usedbook@abe.com";
DropDownSeller.Visible = true;
DropDownSeller.Items.Remove("Chacha Choudary");
DropDownSeller.Items.Remove("SpiderMan");
DropDownSeller.Items.Remove("Amar chitra Katha");
DropDownSeller.Items.Remove("Chandamama");
DropDownSeller.Items.Remove("Mahabharata");
DropDownSeller.Items.Add("Amar chitra Katha");
DropDownSeller.Items.Add("Chandamama");
DropDownSeller.Items.Add("Mahabharata");
DropDownSeller.DataBind();
if (DropDownSeller.SelectedValue == "Amar chitra Katha")
{
lblPrice.Visible = true;
lblPrice.Text = "$69.99";
}
else if (DropDownSeller.SelectedValue == "Chandamama")
{
lblPrice.Visible = true;
lblPrice.Text = "$59.99";
}
else if (DropDownSeller.SelectedValue == "Mahabharata")
{
lblPrice.Visible = true;
lblPrice.Text = "$49.99";
}
else
{
lblPrice.Visible = false;
}
}
对此的任何想法表示赞赏
谢谢,
【问题讨论】:
-
"但是当我从 DDL2 中选择一个项目时,标签内容不显示"。那个事件的代码在哪里?
-
您正在向
DropDownSeller添加项目并检查您刚刚添加的项目是否也被选中? -
@Bala R 我已将 AutoPostBack 值设置为 true
标签: c# asp.net drop-down-menu