當我從此下拉列表(DDL1)中選擇任何項目時導致創建另一個下拉列表(DDL2),其中包含一些下拉列表(DDL1)項目。當我從DDL1中選擇其他項目時,項目將在DDL2中更改,這發生在DDL1中選擇的每個不同項目。從動態添加的下拉列表中選擇項目時看不到標籤內容
當我從DDL2中選擇一個項目時,必須顯示標籤內容,我正在製作Label invisibe,並在代碼中將可見性更改爲true並向其添加內容。但是當我從DDL2中選擇一個項目時,標籤內容不顯示。
這裏是我的代碼
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "Abe Books")
{
DropDownSeller.Visible = true;
lnkUsdBooks.Visible = true;
lnkUsdBooks.Text = "[email protected]";
lnkUsdBooks.NavigateUrl = "mailto:[email protected]";
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項目不顯示的標籤內容」。那個事件的代碼在哪裏? – Dante 2011-05-26 13:31:23
您正在將項目添加到'DropDownSeller'並檢查您剛剛添加的項目是否也被選中了? – 2011-05-26 13:33:27
@Bala R我已經設置了AutoPostBack值爲true – user490706 2011-05-26 13:43:21