protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MyWeb.Web.FillDDL(this.DropDownList1, "请选择", MyWeb.MyData.GetDBList("CodeTye"), "CodeName", "CodeTyeID");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.DropDownList1.SelectedIndex == 0)
{
this.DropDownList2.DataSource = null;
this.DropDownList2.DataBind();
return;
}
string[,] FArr = new string[1, 4];
FArr[0, 0] = "FKeyValue";
FArr[0, 1] = this.DropDownList1.SelectedItem.Text;
FArr[0, 2] = "1";
FArr[0, 3] = "等于";
DataTable CodeDT = MyWeb.MyData.GetDBList("Code", FArr, "CodeID", "1");
MyWeb.Web.FillDDL(this.DropDownList2, "请选择", CodeDT, "FDispValue", "CodeID");
}
其中:FKeyValue和this.DropDownList1.SelectedItem.Text都是汉字。要实现的意思就是,当this.DropDownList1.SelectedItem.Text选择值后自动在Code表里获取带有改文字的所有列表,用DropDownList2显示出来。
{
if (!this.IsPostBack)
{
MyWeb.Web.FillDDL(this.DropDownList1, "请选择", MyWeb.MyData.GetDBList("CodeTye"), "CodeName", "CodeTyeID");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.DropDownList1.SelectedIndex == 0)
{
this.DropDownList2.DataSource = null;
this.DropDownList2.DataBind();
return;
}
string[,] FArr = new string[1, 4];
FArr[0, 0] = "FKeyValue";
FArr[0, 1] = this.DropDownList1.SelectedItem.Text;
FArr[0, 2] = "1";
FArr[0, 3] = "等于";
DataTable CodeDT = MyWeb.MyData.GetDBList("Code", FArr, "CodeID", "1");
MyWeb.Web.FillDDL(this.DropDownList2, "请选择", CodeDT, "FDispValue", "CodeID");
}
其中:FKeyValue和this.DropDownList1.SelectedItem.Text都是汉字。要实现的意思就是,当this.DropDownList1.SelectedItem.Text选择值后自动在Code表里获取带有改文字的所有列表,用DropDownList2显示出来。
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.DropDownList1.SelectedIndex == 0)
{
//选择值
int SelectID=Convert.ToInt32(DropDownList1.SelectedValue); //新建方法
dataBind(SelectID)
}
}
protect dataBind(int id)
{
利用id取得值dataset :ds
datatable dt=ds.Table["XXXX"];
DropDownList1. DataSource =dt;
DropDownList2.DataBind();
DropDownList1.SelectedItem="XXXX";
DropDownList1.SelectedValue="XXXX";}不就是绑完在绑,换值接着绑吗?实在没看懂为什么要你那么写