Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. while (reader.Read())
  2. {
  3. DropDownList1.Items.Insert(i, new ListItem(reader["Text"].ToString(), reader["Valye"].ToString(), true));
  4. i++;
  5. }
  6.  
  7. DataTable source = new DataTable();
  8.  
  9. List<myClass> source = new List<myClass>();
  10.  
  11. DropDownList1.DataSource = source;
  12. DropDownList1.DataTextField = "Text";
  13. DropDownList1.DataValueField = "Value";
  14. DropDownList1.DataBind();
  15.  
  16. SqlDataSource source = new SqlDataSource();
  17. source.SelectCommand = "SELECT * FROM yourTable";
  18. source.ConnectionString = Common.connectionString;
  19.  
  20. DropDownList1.DataSource = source;
  21. DropDownList1.DataTextField = "Text";
  22. DropDownList1.DataValueField = "Value";
  23. DropDownList1.DataBind();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement