samedi 22 juin 2019

Dynamic Dropdown returns first vallue on button click . Not Repeated

Checked all over the internet. None of them properly answering the question. I want a simple and direct solution.

( Ignore this: mam endewnd wknwnw wnxwqnqwnwq xqwmsqw wskwnqsnwqknsqw wsmkwnswqnqw wnskqwnsqwnspoqwnpqw wmnksnwqknkwnnqw nkwsnlnqwpsqwnqwowqpwqpqw )

protected    void    Page_Load(object    sender,    EventArgs    e)
            {
                            EnableViewState    =    true;
                            Areass.EnableViewState    =    true;
                            Button1.EnableViewState    =    true;


                            SqlConnection    conn    =    new    SqlConnection();//(@"Data    Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|Database1.mdf;Integrated    Security=True");
                            conn.ConnectionString    =    @"Data    Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Database.mdf;Integrated    Security=True";
                            conn.Open();


                            SqlCommand    cmds    =    conn.CreateCommand();
                            cmds.CommandText    =    "select    *    from    categories";
                            cmds.ExecuteNonQuery();
                            SqlDataAdapter    das    =    new    SqlDataAdapter(cmds);
                            DataTable    dts    =    new    DataTable();
                            das.Fill(dts);

                            Areass.DataSource    =    dts;
                            Areass.DataTextField    =    "Area";
                            Areass.DataValueField    =    "Id";
                            Areass.DataBind();
                            conn.Close();


            }


protected    void    Button1_Click(object    sender,    EventArgs    e)
            {



                                            TextBox1.Text    =    Areass.SelectedItem.Text;
}




Aucun commentaire:

Enregistrer un commentaire