Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Populate Text boxes based on drop down list in 3 tier application

Tags:

c#

asp.net

3-tier

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'
like image 849
PriceCheaperton Avatar asked Apr 03 '15 09:04

PriceCheaperton


2 Answers

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.

like image 170
senthil Avatar answered Sep 19 '22 16:09

senthil


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;
 }

}
like image 26
Mairaj Ahmad Avatar answered Sep 20 '22 16:09

Mairaj Ahmad