大家看以下代码:假如我按下其他按钮提交给服务器 如何做到DropDownList2,DropDownList3选定项不改变,按我这样做的话结果按下其他按钮提交给服务器后的结果DropDownList2,DropDownList3都为空了,我应该如何修改,谢谢~! this.DropDownList1.DataSource = dbobj.GetprovinceList();
this.DropDownList1.DataTextField = "brtype";
this.DropDownList1.DataValueField = "brtypeid";
this.DropDownList1.DataBind();
this.DropDownList1.Attributes.Add("onchange", "cityResult();");
this.DropDownList2.Attributes.Add("onchange", "areaResult();");
前台:
function cityResult()
{
var city=document.getElementById("DropDownList1");
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
}
function get_city_Result_CallBack(response)
{
if (response.value != null)
{
document.all("DropDownList2").length=0;
var ds = response.value;
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].setype;
var id=ds.Tables[0].Rows[i].setypeid;
document.all("DropDownList2").options.add(new Option(name,id));
}
}
}
areaResult();
return
}
//企业三类----------------------------------------
function areaResult()
{
var area=document.getElementById("DropDownList2");
AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
}
function get_area_Result_CallBack(response)
{
if (response.value != null)
{
document.all("DropDownList3").length=0;
var ds = response.value;
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].thtype;
var id=ds.Tables[0].Rows[i].thtypeid;
document.all("DropDownList3").options.add(new Option(name,id));
}
}
}
return
}
this.DropDownList1.DataTextField = "brtype";
this.DropDownList1.DataValueField = "brtypeid";
this.DropDownList1.DataBind();
this.DropDownList1.Attributes.Add("onchange", "cityResult();");
this.DropDownList2.Attributes.Add("onchange", "areaResult();");
前台:
function cityResult()
{
var city=document.getElementById("DropDownList1");
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
}
function get_city_Result_CallBack(response)
{
if (response.value != null)
{
document.all("DropDownList2").length=0;
var ds = response.value;
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].setype;
var id=ds.Tables[0].Rows[i].setypeid;
document.all("DropDownList2").options.add(new Option(name,id));
}
}
}
areaResult();
return
}
//企业三类----------------------------------------
function areaResult()
{
var area=document.getElementById("DropDownList2");
AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
}
function get_area_Result_CallBack(response)
{
if (response.value != null)
{
document.all("DropDownList3").length=0;
var ds = response.value;
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].thtype;
var id=ds.Tables[0].Rows[i].thtypeid;
document.all("DropDownList3").options.add(new Option(name,id));
}
}
}
return
}
解决方案 »
- 存储过程中使用like
- 导航栏弹出菜单的问题?
- SWFUpload 详细说明和代码案例
- 连接字符 急救
- 我用中文的vs2003开发的aspnet,但一放在澳大利亚的服务器上就乱码,服务器用的是英文版的windows server2003
- 用过XmlValidatingReader的高手请进,让这家伙气的我头晕。。。
- 怎样打印一个所需表单?
- 怎么产生一个长串的字符来做ID?急,马上结贴!
- 论坛帖子无法上传图片,请大狭指教!QQ:56116410
- Win2000 Server为什么装不上.Net
- 时间格式转换问题?
- NHibernate HSQL 怎么在生成的SQL 中的 字符串常量前加上 N 前缀以标识为Unicode编码
是你选中后的值被还原回初始值了吗?postback了?把你绑定下拉框的放到!IsPostBack中去