コード例 #1
0
    protected void ddlItem_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlPackage.SelectedIndex > 0)
        {
            cblBranches.DataSource     = branchProvider.GetAll();
            cblBranches.DataValueField = "ID";
            cblBranches.DataTextField  = "Name";
            cblBranches.DataBind();

            foreach (ListItem item in cblBranches.Items)
            {
                item.Selected = false;
            }

            int[] branchesID = packageProvider.GetBranchesByPackage(Convert.ToInt32(ddlPackage.SelectedValue)).ToArray();
            foreach (var branchID in branchesID)
            {
                cblBranches.Items.FindByValue(branchID.ToString()).Selected = true;
            }
        }
        else
        {
            cblBranches.DataSource = null;
            cblBranches.DataBind();
        }
    }