Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (reader.Read())
- {
- DropDownList1.Items.Insert(i, new ListItem(reader["Text"].ToString(), reader["Valye"].ToString(), true));
- i++;
- }
- DataTable source = new DataTable();
- List<myClass> source = new List<myClass>();
- DropDownList1.DataSource = source;
- DropDownList1.DataTextField = "Text";
- DropDownList1.DataValueField = "Value";
- DropDownList1.DataBind();
- SqlDataSource source = new SqlDataSource();
- source.SelectCommand = "SELECT * FROM yourTable";
- source.ConnectionString = Common.connectionString;
- DropDownList1.DataSource = source;
- DropDownList1.DataTextField = "Text";
- DropDownList1.DataValueField = "Value";
- DropDownList1.DataBind();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement