ArrayList for string - VS2008 - C #

  ArrayList filters = new ArrayList();
  filters.Add(new string[] { "Name", "Equals", "John" });


  ObjectDataSource1.SelectParameters.Add("AppliedFilters", 
           string.Join(",",(string[])filters.ToArray(typeof(string))));

      

I am trying to add a parameter to an object datasource that is bound to my select method, which should accept a string []. But since SelectParameters.Add accepts (string, string) or other 3 overloads that don't seem to work right for me.

The select method takes a string parameter, although I prefer it to accept a string [] or arraylist, but for now I can live with accepting a string, which I have to convert back to a string []

Resolution: following this article link text

Closed as a duplicate of the question above.

0


source to share


2 answers


I think you are wrong.

I suppose it should be code ObjectDataSource1.SelectParameters.Add(filters[0], filters[2));



If you look at the MSDN doc it says the first argument should be the parameter name and the second argument should be the parameter value.

Please read the document carefully.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.parametercollection.add.aspx

0


source


Is this what you mean?

arrList.ToArray(typeof(string)) as string[];

      

Or are you trying to concatenate the strings together?



The mistake I think you are doing here is that I would split them into three different variables, instead of putting them in a list of arrays. In your example:

var filterField = "Name";
var filterComparison = "Equals";
var filterValue = "John";

      

0


source







All Articles