Connecting Tech Pros Worldwide Forums | Help | Site Map

Passing 2 values to a function

Member
 
Join Date: Jul 2007
Posts: 70
#1: Mar 3 '09
Hello

Is it possilble to pass an object and a string to a function?
The object lives on the aspx page and the string live in a seperate function in the .cs page.

My ASPX page has an <%#(ParallelMating(Eval("Gender"))%>

My CS page has

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.    if (Request.QueryString["a"]=="123")
  4. {
  5.    string s = "True";
  6.    ParallelMating(s);
  7. }
  8.  
  9. public string ParallelMating(object o, string s)
  10. {
  11.    string o = Convert.ToString(o);
  12.    if (o == s)
  13.   {
  14.     // do something
  15.   }
  16. }
When I do this, I get the message CS1501: No overload for method 'ParallelMating' takes '1' arguments

Line 170:<%#ParallelMating(Eval("Gender"))%>

(pleae note, the Line170 is from the aspx page)

I can only assume the <%#ParallelMating(Eval)("Gender"))%> needs to also pass a string to the code behind, but again, I have no idea how?

Thanks

Dave

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: Mar 3 '09

re: Passing 2 values to a function


Your ParallelMating function takes two arguments, neither of your usages provide two arguments.
Reply