1
I am trying to fill in the textbox, when the client is typing the initials of his Name, select goes to the bank and tries to get the information. However, I have no idea how to send
I’ll show you my View and my DAL.
View:
<div class="control-group">
<label>Nome</label><asp:TextBox ID="txbAlgNome" runat="server"></asp:TextBox><br />
</div>
<div>
<asp:Button ID="button_cad_1" runat="server" Text="Salvar" onclick="button1_cad_veiculo" />
</div>
View code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Geax1.Model;
using Geax1.DAL;
namespace Geax1.Views
{
public partial class AluguelVeiculos : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//enviando o nome para o SELECT no meu DAL
_AluguelVeiculos aldata = new _AluguelVeiculos();
aldata.Nomecliente1 = txbAlgNome.Text;
_ListaNome.ListaNomeCliente(aldata);
//preenchendo os campos do TextBox, após o select Like
txbAlgNome.DataBinding = _ListaNome.retornaNomecliente();
}
}
}
My DAL:
namespace Geax1.DAL
{
public class _ListaNome
{
private static List<_AluguelVeiculos> lc = new List<_AluguelVeiculos>();
public static void ListaNomeCliente(_AluguelVeiculos obj)
{
using (var conn = new MySqlConnection("server=127.0.0.1;Database=xpto;User ID=root;Password='';"))
{
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = new MySqlCommand("SELECT nome, cpf FROM tab_cliente WHERE nome LIKE '%nome% ;", conn);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
foreach (DataRow linha in dataset.Tables[0].Rows)
{
_AluguelVeiculos cl_1 = new _AluguelVeiculos();
cl_1.Nomecliente1 = Convert.ToString(linha["nome"]);
cl_1.CpfCliente1 = Convert.ToString(linha["cpf"]);
lc.Add(cl_1);
}
}
}
public static List<_AluguelVeiculos> retornaNomecliente()
{
_AluguelVeiculos al = new _AluguelVeiculos();
ListaNomeCliente(al);
return lc;
}
}
}
So? http://jqueryui.com/autocomplete/
– Leonel Sanches da Silva
Yeah, that way.
– Vinícius