I have a ddl
protected void LoadCodCompartiment() { using (SqlConnection conn = new SqlConnection(connString)) { string sqlQuery = "SELECT DISTINCT CodCompartiment FROM tblUser"; using (SqlCommand cmd = new SqlCommand(sqlQuery, conn)) { SqlDataAdapter da = new SqlDataAdapter(cmd); conn.Open(); DataSet ds = new DataSet(); da.Fill(ds); ddlCompartiment.DataSource = ds; ddlCompartiment.DataBind(); } } }
which is loaded at Page_Load.
protected void Page_Load(object sender, EventArgs e) { LoadCodCompartiment(); if(!IsPostBack) { LoadCodCompartiment(); } }
The proble I have is that on first load the values are duplicated
and after I select one value and click on the dropdown again, values are multiplied
I don't understand why is doing so