Need a little Coding Help with Parameter Retrieval in Extensions

Topics: Business Logic Layer, Controls
Nov 14, 2013 at 4:56 PM

Creating a new extension where I a add a series of parameters and am a bit stuck on developing a function that retrieves a particular one using the ExtensionSettings class.

Admin Interface allows me add values for 3 parameters the updating the extensionsetting via the extension manager ... that par works great by the way :)

Here is the code I added during the initialization:
        ExtensionSettings BussinessInformation = new ExtensionSettings("Business Information");

        BussinessInformation.AddParameter("CodeName", "Setting Name", 20, true, false, ParameterType.String);
        BussinessInformation.AddParameter("Code", "Code", 20, true, true, ParameterType.String);
        BussinessInformation.AddParameter("CodeValue", "Replacement Value", 200, true, false, ParameterType.String);

        // describe specific rules for entering parameters
        BussinessInformation.Help = "Key business replacement codes.";

        BussinessInformation.AddValues(new[] { "Business Name", "{[BusinessName]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business Address 1", "{[BusinessAddress1]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business Address 2", "{[BusinessAddress2]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business City", "{[BusinessCity]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business State", "{[BusinessState]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business Zip Code", "{[BusinessZipCode]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business Main Number", "{[BusinessMainNumber]}", string.Empty });
        BussinessInformation.AddValues(new[] { "Business Tracking Number", "{[BusinessTrackingNumber]}", string.Empty });

        _BusinessInformation = ExtensionManager.InitSettings(this.GetType().Name, BussinessInformation);
The Question:

Now i need a function that allows me to look-up the Value of "CodeValue" by the value of "Code" in "_BusinessInformation". How should that look?

I tried a number of variations and function but with no luck, the latest run looked like this:
        DataTable dt = _BusinessInformation.GetDataTable();

        DataRow[] dr = dt.Select("Code = Like'" + settingKey + "'");
It Failed because the GetDataTable() returns and empty set :(

Thanks for your input :)
Nov 15, 2013 at 4:10 PM
Got it to work:
        string _ReplacementValue = "Not found";
        DataTable dt = null;
        DataRow[] dr = null;

        //* Check the BUSINESS information array of values for replacement
        dt = _BusinessInformation.GetDataTable();
        dr = dt.Select("Code = '" + settingKey + "'");

        if (dr.Length > 0)
            _ReplacementValue = dr[0].ItemArray[2].ToString();
            return _ReplacementValue;