dropdwnlist autopostback不能正常工作 我的代码如下:
<asp:DropDownList ID="ddlState" runat="server" Width="200px" AutoPostBack="true" onselectedindexchanged="ddlState_SelectedIndexChanged" >
<%-- <asp:ListItem Selected="True">--Select--</asp:ListItem>--%>
</asp:DropDownList>
Codebehind是:
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
ddlDistrict.Enabled = true;
ddlTaluka.Enabled = true;
DataTable dtObj = new DataTable();
using (var client = ServiceClient<IPallaviAddressManager>.Create("PallaviAddressManager"))
{
dtObj = client.Instance.GetAllStates();
}
var result = (from dt in dtObj.AsEnumerable()
where dt.Field<Int64>("StateID") == Convert.ToInt64(ddlState.SelectedValue)
select dt);
dtObj = result.CopyToDataTable();
ddlDistrict.DataSource = dtObj;
ddlState.DataTextField = "Description";
ddlState.DataValueField = "DistrictID";
}
你能帮忙吗?
答案 0 :(得分:0)
将其设为runat="server"
和autopostback="true"
答案 1 :(得分:0)
尝试添加ddlDistrict.DataBind();在代码的最后,正如Shadow Wizard建议的那样
答案 2 :(得分:0)
听起来事件没有被正确连接。
尝试在设计器中选择DropDownList控件,转到属性选项卡并双击SelectedIndexChanged事件右侧的空间,如果它在代码隐藏中创建了新的存根,则原始事件未被挂钩正常。