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


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

Am trying to add a parameter to my object data source which is bound to my select method which should accept a string[]. But as the SelectParameters.Add takes in (string,string) or the other 3 overloads which do not seem to function for me correctly.

The select method accepts a string param though i prefer it accept a string[] or arraylist, but for now I can live with accepting a string which i should convert back to string[]

Resolution: followed this article link text

Closed as duplicate of the question referenced above.

Community
  • 1
  • 1

2 Answers2

0

I think you are mistaken.

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

If you look at the MSDN Doc, it says the the 1st arg should be parameter name and 2nd arg should be parameter value.

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

shahkalpesh
  • 33,172
  • 3
  • 63
  • 88
  • shahkalpesh: The add has 4 overloads and i figured i would use this one http://msdn.microsoft.com/en-us/library/dxsac270.aspx and create my param name called "AppliedFilters" and convert the arraylist to string –  Nov 14 '08 at 20:23
0

Is this what you meant?

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

Or are you trying to join strings together?

The mistake i think you're making here, is that I would split them up into three different variables, rather than putting them all in an array list. In your example:

var filterField = "Name";
var filterComparison = "Equals";
var filterValue = "John";
aronchick
  • 6,786
  • 9
  • 48
  • 75
  • arronchick: The reason i used an ArrayList is that I can have multiple filters based and didn't want to restrict it to a single filter. I can have "name" "equals" "john" and an additional filter "Date" "<" "10/10/2008". This way my SelectMetjod gets a delimitted value that I can iterate. –  Nov 14 '08 at 20:25