Exemplo n.º 1
0
        public static String getSelectedCSVQuotes(CBLDropDown cbdd)
        {
            String values = String.Empty;
            for (int i = 0; i < cbdd.Items.Count; i++)
                if (cbdd.Items[i].Selected && cbdd.Items[i].Value != "All")
                    values += "','" + cbdd.Items[i].Value;

            if (values.Length > 3) values = values.Substring(3);
            return values;
        }
Exemplo n.º 2
0
        private Dictionary<String, String> Post(List<CBLDropDown.cntrl> cntrls, String Params)
        {
            // script request to update drop down(s)
            // All cntrls need to be sent if needed for filtering

            Dictionary<String, String> dictionary = new Dictionary<String, String>();
            String[] aParams = Params.Split(':');

            DataTable CarData = getCarDataTable(); // use cntrls to filter CarData and populate cascading cntrls

            // you could use other elements (radio button etc) passed in Params for other filtering

            String filter = ""; // "table_column='" + aParams[2] + "'";

            Int32 index = 0; // cntrls.Count

            // Any controls starting with aParams[0] will get rebuilt
            if (aParams[0] == "cbddMake")
            {   // start from top
                using (CBLDropDown cbddMake = new CBLDropDown())
                {
                    cbddMake.DataSource = getArr(CarData,
                                                    "MakeText",
                                                    filter);
                    cbddMake.DataBind();
                    cbddMake.chkd = cntrls[index].chkd;
                    if ((cbddMake.chkd == null || cbddMake.chkd.Length == 0) && cbddMake.Items.Count > 0)
                        cbddMake.SelectedIndex = 0; //select the first if nothing is
                    cbddMake.ID = "cbddMake";
                    cbddMake.Multi = true;
                    cbddMake.selectTitle = "Select Make";
                    cbddMake.nextID = "cbddModel";
                    if (aParams[1] == "cbddMake") // user is waiting for control to open
                        cbddMake.OpenOnStart = true;
                    using (System.IO.StringWriter stringWriter = new System.IO.StringWriter())
                    using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                    {
                        cbddMake.RenderPublic(writer);
                        dictionary.Add("cbddMake", stringWriter.ToString());
                    }
                    filter += " AND MakeText IN ('" + CBLDropDown.getSelectedCSVQuotes(cbddMake) + "')";
                }
            }
            else
                filter += " AND MakeText IN ('" + String.Join("','", cntrls[index].chkd) + "')";

            index++; // now cbddModel

             // If (no model) and sending cbddModel, set to NA
             //   dictionary.Add("cbddModel", CBLDropDown.getNAinnerhtmml("N/A", "cbddModel", "ddlchklst"));

               //     if ((aParams[0] == "cbddModel" || dictionary.Count > 0) && cntrls.Count > index)
                using (CBLDropDown cbddModel = new CBLDropDown())
                {
                    cbddModel.topLevel = "cbddRegion";
                    cbddModel.DataSource = getArr(CarData,
                                                    "Curr_Assigned_Site_Name",
                                                    filter);
                    cbddModel.DataBind();
                    cbddModel.selectTitle = "Select Model";
                    if (cntrls[index].ID == "cbddModel")
                        cbddModel.chkd = cntrls[index].chkd;
                    if ((cbddModel.chkd == null || cbddModel.chkd.Length == 0) && cbddModel.Items.Count > 0)
                        cbddModel.SelectedIndex = 0; //select the first if nothing is
                    cbddModel.ID = "cbddModel";
                    cbddModel.Multi = true;
                    cbddModel.nextID = "cbddOptions";
                    if (aParams[1] == "cbddModel") // user is waiting for control to open
                        cbddModel.OpenOnStart = true;
                    using (System.IO.StringWriter stringWriter = new System.IO.StringWriter())
                    using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                    {
                        cbddModel.RenderPublic(writer);
                        dictionary.Add("cbddModel", stringWriter.ToString());
                    }
                    filter += " AND ModelText IN ('" + CBLDropDown.getSelectedCSVQuotes(cbddModel) + "')";
                }
            //  else if (index < cntrls.Count && cntrls[index].ID == "cbddModel")
            //      filter += " AND ModelText IN ('" + String.Join("','", cntrls[index].chkd) + "')";

            if (cntrls[cntrls.Count - 1].ID == "cbddOptions") // disabled control not sent
                using (CBLDropDown cbddOptions = new CBLDropDown())
                {
                    index = cntrls.Count - 1;
                    cbddOptions.Alltxt = "All";
                    cbddOptions.topLevel = "cbddMake";

                    cbddOptions.DataSource = getArr(CarData,
                                                    "OptionsText",
                                                    filter);
                    cbddOptions.DataBind();
                    cbddOptions.selectTitle = "Select Options";
                    cbddOptions.chkd = cntrls[index].chkd;
                    cbddOptions.ID = "cbddOptions";
                    cbddOptions.Multi = true;
                    if (aParams[1] == "cbddOptions") // user is waiting for control to open
                        cbddOptions.OpenOnStart = true;

                    using (System.IO.StringWriter stringWriter = new System.IO.StringWriter())
                    using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                    {
                        cbddOptions.RenderPublic(writer);
                        dictionary.Add("cbddOptions", stringWriter.ToString());
                    }
                }

            return dictionary;
        }