I would like to populate my text boxes with values based on the selection from my drop down list.
DAL:
public static string GetTicket(collection b)
{
try
{
string returnValue = string.Empty;
DB = Connect();
DBCommand = connection.Procedure("getTicket");
DB.AddInParameter(DBCommand, "@SupportRef", DbType.String, b.SupportRef1);
var myReader = DBCommand.ExecuteReader();
while (myReader.Read())
{
returnValue = myReader.GetString(0);
}
return returnValue;
}
catch (Exception ex)
{
throw ex;
}
BLL:
public string returnTicket(collection b)
{
try
{
string ticket = DAL.data.GetTicket(b);
return ticket;
}
catch (Exception ex)
{
throw ex;
}
}
PL:
protected void ddl_Customers_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedValue = ddl_Customers.SelectedValue.ToString();
//populate the text boxes
txtSupportRef.Text = bobj.returnTicket(selectedValue);
}
My Stored Procedure has got a variable called SupportRef which needs a value before it can return results.
I get the following errors:
The best overloaded method match for 'BLL.business.returnTicket(DAL.collection)'
has some invalid arguments
AND
Argument 1: cannot convert from 'string' to 'DAL.collection'
Yes, From the Form you are trying to pass an String value to the Business layer method returnTicket(collection b). But in this Business layer method returnTicket(collection b) signature has the collection type argument to be accepted. After selecting the value from the dropdown, the selected value is stored in the string variable. Please change the collection type of the BLL and DAL's method to the string type. This change will resolve the above error.
You need to pass string
type argument to returnTicket of BLL
and GetTicket of DAL
.Change your methods like this
BLL
public string returnTicket(string supportRef)
{
try
{
string ticket = DAL.data.GetTicket(supportRef);
return ticket;
}
catch (Exception ex)
{
throw ex;
}
}
DAL
public static string GetTicket(string supportRef)
{
try
{
string returnValue = string.Empty;
DB = Connect();
DBCommand = connection.Procedure("getTicket");
DB.AddInParameter(DBCommand, "@SupportRef", DbType.String, supportRef);
var myReader = DBCommand.ExecuteReader();
while (myReader.Read())
{
returnValue = myReader.GetString(0);
}
return returnValue;
}
catch (Exception ex)
{
throw ex;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With