I’m trying to use the Library to enhance the power of a dropdown list though there’s an issue within the drop-down list the content appears twice and I have no clue why.
Using jquery and asp.net:
the jquery function is called once.
you guys can ignore the ScriptManager function. I already try to delete it.
DataTable CountriesDT = DataRepository.CountryProvider.CountriesGetAll().Tables[0];
DDLCountry.Items.Add(new ListItem(Translate(Tag.SELECT), "0"));
DDLInvoiceCountry.Items.Add(new ListItem(Translate(Tag.SELECT), "0"));
if (CountriesDT != null)
{
for (int k = 0; k < CountriesDT.Rows.Count; k++)
{
ListItem myListItem = new ListItem(CountriesDT.Rows[k]["CountryName"].ToString(), CountriesDT.Rows[k]["CountryID"].ToString());
ListItem myListInvoiceItem = new ListItem(CountriesDT.Rows[k]["CountryName"].ToString(), CountriesDT.Rows[k]["CountryID"].ToString());
DDLCountry.Items.Add(myListItem);
DDLInvoiceCountry.Items.Add(myListInvoiceItem);
}
ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "initSelect22", "initSelect2Ddl2();", true);
}
function initSelect2Ddl2() {
$("#<%=DDLCountry.ClientID %>").select2();
$("#<%=DDLCity.ClientID %>").select2();
}