How to join value of 2 radtextboxes?

2 posts, 0 answers
  1. Cristian
    Cristian  avatar
    46 posts
    Member since:
    May 2011

    Posted 27 May 2011 Link to this post

    Hi, I´m new developer and working with telerik controls, in my app I have 3 textboxes, the first one is for ID of customers, the second is for name and the third one is for last name. I use this textboxes to search custumers and populate them in a radGrid when a button is pressed, now the searching only works with only one textbox, I mean, if I put the ID in the Id textbox I get as reseult the customer corresponding to that ID, if I put the name it shows me all the customers that matches with the name, and is the same case for the last name, but if I put both name and last name I only get the results of the last textbox I fill, How can I make the search with both values, the name and last name?
     Here is the code that I implement when clicking the search button.
    Hope you could help me.
    protected void btnBuscar_Click(object sender, EventArgs e)
                  if (rdTxtExp.Text == "" && rdTxtApat.Text == "" && rdTxtAmat.Text == "" && rdTxtNom.Text == "")
                    Alerta("Captura al menos un criterio de busqueda");
            private void BuscaSolicitanteGrid()
                    var bdInstContext = new BD_INSTEntities();
                    var empleados = from emp in bdInstContext.Empleados
                                    where emp.exp_emp == rdTxtExp.Value
                                    select emp;
                    rgSolic.DataSource = empleados;
                    if (rdTxtNom.Text != "")
                        var bdInstContextNom = new BD_INSTEntities();
                        var empleadoNom = bdInstContextNom.Empleados.Where("it.nombre_emp = '" + rdTxtNom.Text + "'");
                        //var empleadoNom = from emp in bdInstContextNom.Empleados
                        //                where emp.nombre_emp == rdTxtNom.Text
                        //                select emp;
                        rgSolic.DataSource = empleadoNom;
                    if (rdTxtApat.Text != "")
                        var bdInstContextApat = new BD_INSTEntities();
                        var empleadoApat = from emp in bdInstContextApat.Empleados
                                           where emp.paterno_emp == rdTxtApat.Text
                                           select emp;
                        rgSolic.DataSource = empleadoApat;
                    if (rdTxtAmat.Text != "")
                        var bdInstContextAmat = new BD_INSTEntities();
                        var empleadosAmat = from emp in bdInstContextAmat.Empleados
                                            where emp.materno_emp == rdTxtAmat.Text
                                            select emp;
                        rgSolic.DataSource = empleadosAmat;
  2. Genti
    Genti avatar
    107 posts

    Posted 28 May 2011 Link to this post

    Hi Cristian José,

    I suggest you update your LINQ statements and include in the queries both name and surname.
    For example, in the case that both values are supplied then you can do the following:
    var query = from .... where emp.NAME == txtName.Value OR emp.SURNAME == txtSurname.Value
    Thus the grid would display data that matches both textboxes.

    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top