0

I´m trying to make a simple filter for my table. I have an aspx page that has a label text. I want to use that text to condition my query. Normally I would just use label.text as the value, but since im working in another layer it won´t work.

How could I make my program understand that it has to use the text from the label of my asp page?

Here´s my code.

public static List<DTO.vEmpleado> GetEmpleadoList()
{
    if (//label is empty)
    {
        return DataAccess.Generic.GetAll<DTO.vEmpleado>(); //this works just fine
    }
    else
    {
        return Common.DataContext.vEmpleado.Where(x => x.Nombre == //label.text).ToList(); //this works fine if I replace label.text with something like "Richard"
    }
}
4
  • Can you show the code around where you are using this method? Commented May 31, 2017 at 13:36
  • why can't you change the GetEmpleadoList() Method to take a string name input.. I think we need to see how you are getting and or passing the label.Text Commented May 31, 2017 at 13:39
  • That´s pretty much what I want to do. I need help passing my label.text from my asp page to this layer. @MethodMan Commented May 31, 2017 at 13:42
  • I do not see where the issue is .. I would google how to construct a querystring in asp.net, or how to store values in a Session Variable if you are going to be passing it to a Page_Load in a web Application.. Commented May 31, 2017 at 13:54

1 Answer 1

3

Instead of directly reading the control, send that value to your method:

public static List<DTO.vEmpleado> GetEmpleadoList(string name)
{
   return Common.DataContext.vEmpleado.Where(x => x.Nombre == name);
}

and call it with

var list = GetEmpleadoList(label.text);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.