c# - 根据 3 层应用程序中的下拉列表填充文本框

标签 c# asp.net 3-tier

我想根据从下拉列表中选择的值来填充我的文本框。

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/

相关文章:

c# - ASP.Net MVC 身份模型中的子类未保存在数据库中

c# - 是否可以为 asp :Calendar 添加新的下一个和上一个按钮

c# - 从几个重叠的 png 中创建一个 jpeg

asp.net - 工作线程和 I/O 线程有什么区别?

c# - Linq to Entities - 三层架构

c# - 如何枚举所有任务,如 Visual Studio 任务窗口

c# - 检测从数组中单击了哪个按钮

c# - 如何在业务实体上封装业务逻辑?

amazon-web-services - 单体架构和三层架构有什么区别?

c# - Excel 互操作在装有 Office 2007 的机器上工作,但在装有 Office 2010 的机器上失败