5
Good morning, I’m using dropdownlist
in the asp.net
to load some data coming from the database, however I do not know the amount that will be shown, because it depends on the fill in the database.
I would like to show only a certain amount of items.
For example, if you have 29 records, I want to show only the first 5 and after that show scrollbar, always with 5 records.
But any way I try I can’t, there is some way to limit the amount of dropdownlist
which is completed by the database?
Dropdownlist:
<asp:DropDownList ID="cbfuncionario" runat="server" style = "overflow-y: scroll"></asp:DropDownList>
and here I load the dropdownlist:
public void CarregaFuncionario()
{
SqlCommand comando = new SqlCommand();
comando.Connection = clsdb.AbreBanco();
comando.CommandType = CommandType.Text;
comando.CommandText = "select pessoa.id,nome FROM [pessoa] inner join classificacoes on classificacoes.id = pessoa.classificacao_id where estado <> 'Inativo' and estado <> 'Excluido' and classificacoes.tipo = '1' order by pessoa.nome ASC";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comando;
DataSet ds = new DataSet();
da.Fill(ds);
cbfuncionario.DataSource = ds.Tables[0];
cbfuncionario.DataTextField = "nome";
cbfuncionario.DataValueField = "id";
cbfuncionario.DataBind();
}
You can put the code?
– PauloHDSousa
I changed the question including the code. Thank you.
– Mariana