Short Answer
In your presentation layer, map the string
type into the DAL.collection
type. You can see this here.
protected void ddl_Customers_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedValue = ddl_Customers.SelectedValue.ToString();
// map the string to a DAL.collection
var collection = new DAL.collection();
collection.SupportRef1 = selectedValue;
//populate the text boxes
txtSupportRef.Text = bobj.returnTicket(collection);
}
Explanation
Both of the errors are compilation errors. You can see a recreation of them both in this fiddle.
Error 1
The best overloaded method match for 'BLL.business.returnTicket(DAL.collection)' has some invalid arguments
The compiler is trying to find a method called BLL.business.returnTicket
that takes a single argument. In the match that it finds, the method takes a single DAL.collection
argument. You're passing it a string
instead, which is an invalid argument, because a string
is not a DAL.collection
. From MSDN:
Overload resolution is a compile-time mechanism for selecting the best function member to invoke given an argument list and a set of candidate function members.
Error 2
Argument 1: cannot convert from 'string' to 'DAL.collection'
Since BLL.business.returnTicket
takes a DAL.collection
argument, the compiler tries to convert the string
into a DAL.collection
. It fails because there is no implicit conversion from a string
type to a DAL.collection
type. From MSDN:
Implicit conversions: No special syntax is required because the conversion is type safe and no data will be lost.
What to do?
There are a few approaches you could take, in order of complexity.
In your presentation layer, map the string
type to the DAL.collection
type. Recommended.
In your business layer, create a new returnTicket(string)
method overload, in addition to the existing one, which maps the string
to the DAL.collection
class. Recommended.
Change both returnTicket(DAL.collection)
and GetTicket(DAL.collection)
to take a string
instead of a DAL.collection
. This has two downsides: it will break other code that currently calls those methods with a DAL.collection
argument and it requires changing four lines of code in two different methods.
Create a user-defined conversion from string
into DAL.collection.
Downside: this is likely overkill.
Recommended things to do
In your presentation layer, convert or to map the string
type into the DAL.collection
type. That is what the short answer above accomplishes.
Alternatively, in your business layer, create a new returnTicket(string)
method overload, in addition to the existing method. It would look like this.
public string returnTicket(collection b)
{
// map the string to a DAL.collection
var collection = new DAL.collection();
collection.SupportRef1 = selectedValue;
// call the existing method that takes a DAL.collection
returnTicket(b);
}