我在更新面板中放了2个Dropdownlist。每当第一个下拉列表选择索引更改第二个下拉列表的项目更改。(如国家/地区..在我的情况下,这是其城市区域)。
每当我更改第一个下拉列表(DDLCity1)selectedindex没问题,它工作正常。但仅两次。 假设,在页面加载后我选择“LA”没问题,LA的区域将加载到另一个下拉列表DDLArea1中。然后我做了更改,选择“纽约”城市,再次下拉列表将正常工作。
但是现在他们试图我的第二个下降列表显示没有变化!!!!!它仍然显示最后的结果。
IN SORT,回发只能工作2次。
进行测试我在下拉列表的indexchange上放了一个警告消息,它只弹出2次。好像回发只有2次:((plzz帮帮我;
<pre>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ViewStateMode="Enabled" UpdateMode="Always">
<ContentTemplate>
<asp:DropDownList ID="DDLCity1" runat="server" AutoPostBack="false" OnSelectedIndexChanged="DDLCity_SelectedIndexChanged"
ViewStateMode="Enabled">
<asp:ListItem Text="- All City -" />
</asp:DropDownList>
<asp:DropDownList ID="DDLArea1" runat="server" Style="margin-bottom: 0px" OnSelectedIndexChanged="DDLArea_SelectedIndexChanged"
AutoPostBack="false" ViewStateMode="Enabled">
<asp:ListItem Text="- Anywhere -" />
</asp:DropDownList>
<span style="position: absolute;">
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="img/loading.gif" alt="Alternate Text" />
</ProgressTemplate>
</asp:UpdateProgress>
</span>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDLCity1" EventName="SelectedIndexChanged" />
</Triggers>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDLArea1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<code>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DDLCity1.DataSource = objsql.GetTable("select distinct city from tblCity where status=1 order by city");
DDLCity1.DataTextField = "city";
DDLCity1.DataValueField = "city";
DDLCity1.DataBind();
DDLCity1.Items.Insert(0, new ListItem("- All India -", "- All India -"));
if (Request.Cookies["ddCityCookie"] != null)
{
ddlCity.SelectedIndex = int.Parse(Request.Cookies["ddCityCookie"].Value);
if (Request.Cookies["ddAreaCookie"] != null)
{
ddlArea.SelectedIndex = int.Parse(Request.Cookies["ddAreaCookie"].Value);
}
}
}
protected void DDLCity_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownCityIndexChange();
DDLArea1.SelectedIndex = 0;
}
protected void DDLArea_SelectedIndexChanged(object sender, EventArgs e)
{
HttpCookie ddAreaCookie = new HttpCookie("ddAreaCookie");
ddAreaCookie.Value = DDLArea1.SelectedIndex.ToString();
ddAreaCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(ddAreaCookie);
}
public void DropDownCityIndexChange()
{
DDLArea1.Items.Clear();
DDLArea1.DataSource = null;
HttpCookie ddCityCookie = new HttpCookie("ddCityCookie");
ddCityCookie.Value = DDLCity1.SelectedIndex.ToString();
ddCityCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(ddCityCookie);
DataSet ds = new DataSet();
if (DDLCity1.SelectedItem.Text != "- All India -")
{
DataTable dt = new DataTable();
dt = objsql.GetTable("select area from tblCity where city='" + DDLCity1.SelectedItem.Text + "' and status=1 order by area");
if (dt.Rows[0]["area"].ToString() != null && dt.Rows[0]["area"].ToString() != "")
{
DDLArea1.DataSource = dt;
DDLArea1.DataTextField = "area";
DDLArea1.DataValueField = "area";
DDLArea1.DataBind();
}
}
DDLArea1.Items.Insert(0, new ListItem("- Anywhere -", "- Anywhere -"));
}
</code>
答案 0 :(得分:0)
删除ClientIDMode =&#34;静态&#34;属性格式