Answers for "bind dropdownlist with datatable in asp.net c#"

C#
1

assign datasource to dropdownlist in c#

cmd.CommandText = " Select * From GetUsersID";
        cmd.Connection = conn;
        conn.Open();
        DataTable dt  = new DataTable();

        dt.Load(cmd.ExecuteReader());
        conn.Close();

        DropDownList1.DataSource = dt;
        DropDownList1.DataTextField = "Name";
        DropDownList1.DataValueField = "ID";
        DropDownList1.DataBind();
Posted by: Guest on June-23-2020

C# Answers by Framework

Browse Popular Code Answers by Language