三级联动选择值变化问题,来者有分!有点急,在线等
我现在用Datalist做了一个三级联动,但到了最后一个,它的值不会跟我选择的变化而变化?(我的意思是: 品牌(下拉) 系列(下拉) 具体某一个产品(下拉) ;就在具体某一产品的时,它只默认最上面的一个,我选了其它产品,但它的ID值就是不变,是怎么回事)
源码如下:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
ddlCategoryBind();
ddlCategory1Bind();
ddlCategory2Bind();
Label2.Text = ddlCategory2.SelectedValue;
}
}
private void ddlCategoryBind()
{
Db.Category myCategory = new Db.Category();
DataSet ds = myCategory.dsCategoryDeepID4( "4 ");
ddlCategory.DataSource = ds.Tables[0].DefaultView;
ddlCategory.DataTextField = "Category ";
ddlCategory.DataValueField = "OrderID ";
ddlCategory.DataBind();
}
private void ddlCategory1Bind()
{
Db.Category myCategory = new Db.Category();
DataSet ds = myCategory.dsCategoryFatherID4(ddlCategory.SelectedValue);
/*(能不能帮我解释一下这注释代码,谢谢 for(int i=0;i <ds.Tables[0].Rows.Count;i++)
{
if(ds.Tables[0].Rows[i][2].ToString()== "001 ")
{
ds.Tables[0].Rows[i][3] = ds.Tables[0].Rows[i][3].ToString();
}
else
{
for(int j=1;j <int.Parse(ds.Tables[0].Rows[i][2].ToString());j++)
{
ds.Tables[0].Rows[i][3] = "|__ " + ds.Tables[0].Rows[i][3].ToString();
}
}
}*/
ddlCategory1.DataSource = ds.Tables[0].DefaultView;
ddlCategory1.DataTextField = "Category ";
ddlCategory1.DataValueField = "OrderID ";
ddlCategory1.DataBind();
Label3.Text =ddlCategory.SelectedValue;
}
private void ddlCategory2Bind()
{
Db.Category myCategory = new Db.Category();
DataSet ds = myCategory.dsCategoryFatherID41(ddlCategory1.SelectedValue);
ddlCategory2.DataSource = ds.Tables[0].DefaultView;
ddlCategory2.DataTextField = "proname ";
ddlCategory2.DataValueField = "ID ";
ddlCategory2.DataBind();
Label1.Text = ddlCategory1.SelectedValue;
}
private void ddlCategory_SelectedIndexChanged(object sender, System.EventArgs e)
{
ddlCategory1Bind();
}
private void ddlCategory1_SelectedIndexChanged(object sender, System.EventArgs e)
{
ddlCategory2Bind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>