Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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(); 
Source by www.codeproject.com #
 
PREVIOUS NEXT
Tagged: #assign #datasource #dropdownlist
ADD COMMENT
Topic
Name
4+2 =