Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dropdown that populates with the selection of another dropdown.
I first clear this dropdown and then populate it, and I have several more of these that are linked to other dropdowns, and the others work great except the last one, which on certain selected indexes, it resets to the first value.
I have set autopostback to true, but don't know what else to do, and I am not getting any result from mysql db.
What I am trying to do with this last dropdown is return the values of a field in a db table, if they are found, depending on multiple criteria found in the where clause.

What I have tried:

String connString = System.Configuration.ConfigurationManager.ConnectionStrings["web"].ToString();
        conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
        conn.Open();
        queryStr = "";
        queryStr = "SELECT * FROM avance_actividad where idProyecto='" + idproy + "' and idObjetivo='" + obj.SelectedIndex + "' and idResultado='" + res.SelectedIndex + "' and idActividad='" + act.SelectedIndex + "'";
        cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
        //con.Open();
        var reader = cmd.ExecuteReader();
        while (reader.Read() && reader.HasRows)
        {
            // here could be problems if database value is null
            es.Text = reader["estado"].ToString();
            com.Text = reader["comentario"].ToString();
            por.Text = reader["porcentaje"].ToString();
        }
        conn.Close();
Posted
Updated 27-Jan-18 3:22am
v2
Comments
Member 10850253 27-Jan-18 10:12am    
I think I found one problem, but I am still having the same issue.
The problem is that in the selectedindex change event, I was using the index of that field.
What I did is instead of calling the selected index changed event, I used a button, but even so, after selection in that dropdown, the values in it reset.
Kornfeld Eliyahu Peter 28-Jan-18 8:42am    
Have you used any AJAX in your page? If not - or if used it wrong - you probably have a full post on value change, and that resets the page back to the original...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900