protected void Page_Load(object sender, EventArgs e)
{



        bindbranches();
        bindbranches1();

}
public void bindbranches()
{
    DataTable dtbranch = new DataTable();
    dtbranch = objsupplyBAL.getbrnch();

    ddlbranch.DataSource = dtbranch;
    ddlbranch.DataBind();
    ddlbranch.Items.Add(new ListItem("--select--", "0"));
    ddlbranch.SelectedIndex = ddlbranch.Items.Count - 1;

}
public void bindbranches1()
{
    DataTable dt = new DataTable();
    dt = objsupplyBAL.getbrnch();

    ddlbranch1.DataSource = dt;
    ddlbranch1.DataBind();
    ddlbranch1.Items.Add(new ListItem("--select--", "0"));
    ddlbranch1.SelectedIndex = ddlbranch1.Items.Count - 1;

}


我的下拉列表没有刷新就不会绑定。如果我选​​择一个下拉列表,则另一个刷新。我必须在代码中添加额外的内容。谁能告诉...

最佳答案

protected void Page_Load(object sender, EventArgs e)
{
  if(!IsPostBack)
 {

    bindbranches();
    bindbranches1();
  }
}


如果您添加它...它工作正常...请首先尝试...

10-07 16:16