private void SelectProduct(string typeID, string type, string productID, string productName, string color, string combinationID, string size, string colorLens, string rxLens, string rxLensID, string rxLensDetails, string amount)
    {
        var ctx = new MoscotDataClassesDataContext();

        if (TypesDropDownList.Items.Count == 0)
        {
            return;
        }


        // If it is not lens type.
        TypesDropDownList.Items.FindByText(type).Selected = true;
        ProductDropDownList.Items.FindByValue(productID.ToString()).Selected = true;

        // For lens types.li
        if (typeID == "33")
        {
            PrescriptionView(size);
            if (!string.IsNullOrEmpty(rxLensDetails))
            {
                // Select Priscription Descriptions.
                SelectPriscriptionDescriptions(rxLensDetails);
            }
        }

        populateColors(Convert.ToInt32(productID));
        ColorDropDownList.Items.FindByText(color).Selected = true;

        populateSizes(Convert.ToInt32(productID), color);

        if (string.IsNullOrEmpty(rxLensDetails))
        {
            var productAttributeCombination = ctx.mss_ProductAttributeCombinations.FirstOrDefault(c => c.CombinationId == Convert.ToInt32(rxLensID));
            if (productAttributeCombination != null)
            {
                FrameTypeDropDownList.SelectedValue = productAttributeCombination.Sku.ToString();
            }
        }
        else
        {
            FrameTypeDropDownList.SelectedValue = "2";
            PrescriptionPanel.Visible           = true;

            PrescriptionDropDownList.SelectedValue = rxLensID.ToString();

            // Shows.. oDAPDropDownList && oSAPDropDownList
            PrescriptionDropDownList_SelectedIndexChanged(PrescriptionDropDownList, null);

            // Select Priscription Descriptions.
            SelectPriscriptionDescriptions(rxLensDetails);
        }
    }
    private void PopulateProducts(ref LinqDataSourceSelectEventArgs e)
    {
        int typeID   = Convert.ToInt32(e.WhereParameters["TypeID"]);
        var ctx      = new MoscotDataClassesDataContext();
        var products = from p in ctx.mss_Products
                       join i in ctx.mss_Indexes on p.ProductID equals i.ProductID
                       orderby p.ProductName
                       where i.TypeID == typeID
                       select new
        {
            p.ProductID,
            p.ProductName
        };

        e.Result = products;
    }
    /// <summary>
    /// Handles the SelectedIndexChanged event of the PrescriptionDropDownList control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void PrescriptionDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        var lensDropDownList = sender as DropDownList;

        if (lensDropDownList.SelectedValue != "0")
        {
            // Update Notes with prescription details.
            int combinationID     = Convert.ToInt32(lensDropDownList.SelectedValue);
            var prescriptionPanel = lensDropDownList.Parent as Panel;

            // Visible ODAP & OSAP
            using (var ctx = new MoscotDataClassesDataContext())
            {
                double sku = ctx.mss_ProductAttributeCombinations.FirstOrDefault(p => p.CombinationId == combinationID).Sku;
                ODAPDropDownList.Visible = sku == 7000000004 || sku == 7000000005;
                OSAPDropDownList.Visible = sku == 7000000004 || sku == 7000000005;
            }
        }
    }