我有德勒克邦退学和德勒邦退学名单。 ddlState正在更新小组。 在选择国家时,我利用选定的国家资格指数变化活动,使国家人口众多。 我将起始值“-1”提高到了约束后退学的两倍,如果退学内容为[当选]价值“-1”,则在 Java文中检查,然后提醒人们注意并退回错误。
但是,对于干.的国家来说,补偿是适当的,而对于干.的国家来说,其价值在加亚克斯更新小组火灾和验证失败后成为“空白”。
如何解决这些问题? 我无意知道,为何在阿斯辛茨·波斯特·巴克谢格之后,损失了dl国家的价值。
//javascript validation
function validateForm()
{
if (ddlCountry .value == "-1")
{
alert("Country should not be blank.");
ddlCountry .focus();
return false;
}
if (ddlState .value == "-1")
{
alert("State should not be blank.");
ddlState .focus();
return false;
}
return true;
}
//Aspx code
<asp:DropDownList ID="ddlCountry " runat="server" CssClass="csstextbox" Width="207px"
AutoPostBack="true" OnSelectedIndexChanged="ddlCountry _SelectedIndexChanged">
</asp:DropDownList>
<asp:UpdatePanel ID="updatePanelState" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlState " runat="server" CssClass="csstextbox" Width="177px">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
//Code Behind
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindCountry();
}
}
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
int countryID = Convert.ToInt32(ddlCountry.SelectedItem.Value);
ifcountryID == -1)
{
return;
}
strSQL = @"SELECT State_ID,State_Desc
FROM State_Master
WHERE countryID = " + countryID + @" ;
DataTable dataTableState = null;
dataTableState = objSqlDbComm.ExecuteDatasetQuery(strSQL).Tables[0];
var dictioneryState = new Dictionary<int, string>();
foreach(DataRow dr in dataTableStudy.Rows)
{
dictioneryState .Add(Convert.ToInt32(dr["State_ID"]), dr["State_Desc"].ToString());
}
ddlState.DataTextField = "Value";
ddlState.DataValueField = "Key";
ddlState.DataSource = dictioneryState;
ddlState.DataBind();
ddlState.Items.Insert(0, new ListItem("[Select]", "-1"));
ddlState.Items[0].Selected = true;
}