我想根据从下拉列表中选择的值来填充我的文本框。
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);
}
我的存储过程有一个名为 SupportRef 的变量,它需要一个值才能返回结果。
我收到以下错误:
The best overloaded method match for 'BLL.business.returnTicket(DAL.collection)'
has some invalid arguments
和
Argument 1: cannot convert from 'string' to 'DAL.collection'
最佳答案
是的,您正试图从表单中将字符串值传递给业务层方法 returnTicket(collection b)。但是在此业务层方法 returnTicket(collection b) 签名中具有要接受的集合类型参数。 从下拉列表中选择值后,所选值将存储在字符串变量中。 请将BLL和DAL的方法的集合类型改为字符串类型。 此更改将解决上述错误。
关于c# - 根据 3 层应用程序中的下拉列表填充文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29429855/