コード例 #1
0
        private void DisplayAvailableAndSelectedSuppliers()
        {
            if (hdnCategoryId.Value.Trim() != "")
            {
                CategoryTransaction cat = new CategoryTransaction();
                lblSupplierCategory.Text = cat.GetCategoryNameById(connstring, hdnCategoryId.Value.Trim());

                string allSelectedVendors = "";
                if (hdnSuppliers.Value.Trim() == "")
                {
                    if (hdnOTS.Value.Trim() == "")
                    {
                        allSelectedVendors = "";
                    }
                    else
                    {
                        allSelectedVendors = hdnOTS.Value.Trim();
                    }
                }
                else
                if (hdnOTS.Value.Trim() == "")
                {
                    allSelectedVendors = hdnSuppliers.Value.Trim();
                }
                else
                {
                    allSelectedVendors = hdnSuppliers.Value.Trim() + "," + hdnOTS.Value.Trim();
                }

                SupplierTransaction sup         = new SupplierTransaction();
                DataSet             ds          = sup.GetSuppliersByCategoryId_FilteredList(connstring, hdnCategoryId.Value.Trim(), "", allSelectedVendors);
                DataTable           dtAvailable = new DataTable();
                DataTable           dtSelected  = new DataTable();
                if (ds.Tables.Count > 0)
                {
                    try
                    {
                        if (ds.Tables[0] != null)
                        {
                            dtAvailable = ds.Tables[0];
                        }
                        if (ds.Tables.Count > 1)
                        {
                            if (ds.Tables[1] != null)
                            {
                                dtSelected = ds.Tables[1];
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                lstSupplierA.DataSource     = dtAvailable;
                lstSupplierA.DataTextField  = "VendorName";
                lstSupplierA.DataValueField = "VendorId";
                lstSupplierA.DataBind();

                lstSupplierB.DataSource     = dtSelected;
                lstSupplierB.DataTextField  = "VendorName";
                lstSupplierB.DataValueField = "VendorId";
                lstSupplierB.DataBind();
            }
        }