页面联动的问题

yayexing 2012-10-19 11:05:27
主要实现联动动功能
1. 现在有四个aspxcombobox框,分别是 门店,国家,省,市。
2. 更改门店会将国家。省。市的当前选择项设置为该门店所在的国家,省。市
3. 选择国家,省的数据源更改为该国家下的省;选择省,市的可选项更改为该省下的市


现在的问题是:选择门店后,不能成功赋值给国家,省,市(赋值方式:控件名.Value=国家ID)
备注:门店,国家,省,市的数据源都绑定的是objectdatasource控件

代码如下所述:
/////////////////////////////////////后台代码//////////////////////////////////////////////////
//修改门店后调用的方法
protected void country_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
SessionState.RemoveValue("ProvinceByCountry");
SessionState.RemoveValue("CityByProvince");
SessionState.RemoveValue("CurrStore");
if (dlCreateStore.SelectedItem != null && dlCreateStore.SelectedItem.Value != null)
{
Store st = new XPCollection<Store>(theSession, CriteriaOperator.Parse("Store_Id = ?", dlCreateStore.SelectedItem.Value.ToString()), null).First();
SessionState.SetValue("CurrStore", st);
if (st.Country_Id != null)
{
SessionState.SetValue("ProvinceByCountry", st.Country_Id.Country_Id);
}
if (st.Province_Id != null)
{
SessionState.SetValue("CityByProvince", st.Province_Id.Province_Id);
}

dlCountry.DataBind();
dlProvince.DataBind();
dlCity.DataBind();

if (dlCountry.Items.Count > 0 && st.Country_Id != null)
{
dlCountry.Value = st.Country_Id.Country_Id;
}
else
{
dlCountry.SelectedIndex = -1;
}


if (dlProvince.Items.Count > 0 && st.Province_Id != null)
{
dlProvince.Value = st.Province_Id.Province_Id;
}
else
{
dlProvince.SelectedIndex = -1;
}

if (dlCity.Items.Count > 0 && st.City_Id != null)
{
dlCity.Value = st.City_Id.City_Id;
}
else
{
dlCity.SelectedIndex = -1;
}
}
}

//修改国家后调用的方法
protected void province_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
if (SessionState.GetValue("CurrStore") == null)
{
SessionState.RemoveValue("ProvinceByCountry");
SessionState.RemoveValue("CityByProvince");
SessionState.RemoveValue("CurrStore");
if (dlCountry.SelectedItem != null && dlCountry.SelectedItem.Value != null)
{
SessionState.SetValue("ProvinceByCountry", dlCountry.SelectedItem.Value.ToString());
dlProvince.DataBind();
dlCity.DataBind();
}

dlProvince.SelectedIndex = -1;
dlCity.SelectedIndex = -1;
}
else
{
Store st = (Store)SessionState.GetValue("CurrStore");
if (dlProvince.Items.Count > 0 && st.Province_Id != null)
{
dlProvince.Value = st.Province_Id.Province_Id;
}
else
{
dlProvince.SelectedIndex = -1;
SessionState.RemoveValue("CurrStore");
}
}
}

//修改省后调用的方法
protected void city_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
if (SessionState.GetValue("CurrStore") == null)
{
SessionState.RemoveValue("CityByProvince");
SessionState.RemoveValue("CurrStore");
if (dlProvince.SelectedItem != null && dlProvince.SelectedItem.Value != null)
{
SessionState.SetValue("CityByProvince", dlProvince.SelectedItem.Value.ToString());
dlCity.DataBind();
}
dlCity.SelectedIndex = -1;
}
else
{
Store st = (Store)SessionState.GetValue("CurrStore");
if (dlCity.Items.Count > 0 && st.City_Id != null)
{
dlCity.Value = st.City_Id.City_Id;
}
else
{
dlCity.SelectedIndex = -1;
}
SessionState.RemoveValue("CurrStore");
}
}
////////////////////////////////end//////////////////////////////////////


/////////////////////////////////前台html代码//////////////////////////
<script type="text/javascript">
function OnStoreChanged(createStore) {
country.PerformCallback(createStore.GetValue().toString());
province.PerformCallback();
city.PerformCallback();
}

function OnCountryChanged(country) {
province.PerformCallback(country.GetValue().toString());
}

function OnProvinceChanged(province) {
city.PerformCallback(province.GetValue().toString());
}
</script>

<td class="style16" colspan="3">
<dx:ASPxComboBox ID="dlCreateStore" runat="server"
DataSourceID="odsStore"
TextField="Store_Name" ValueField="Store_Id" Width="319px"
ClientInstanceName="createStore" OnCallback="createStore_Callback">

<ClientSideEvents SelectedIndexChanged="function(s, e) {
OnStoreChanged(s);
}" />
</dx:ASPxComboBox>
</td>


<td class="style27">
<dx:ASPxComboBox ID="dlCountry" runat="server"
DataSourceID="odsCountry"
TextField="Country_Name" ValueField="Country_Id" Width="100px"
ClientInstanceName="country" OnCallback="country_Callback">
<ClientSideEvents SelectedIndexChanged="function(s, e) {
OnCountryChanged(s);
}" />
</dx:ASPxComboBox>


<td class="style16">
<dx:ASPxComboBox ID="dlProvince" runat="server"
DataSourceID="odsProvince"
TextField="Province_Name" ValueField="Province_Id" Width="100px"
ClientInstanceName="province" OnCallback="province_Callback">
<ClientSideEvents SelectedIndexChanged="function(s, e) {
OnProvinceChanged(s);
}" />
</dx:ASPxComboBox>
</td>
//////////////////////////////////end/////////////////////////////////
...全文
53 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧