I am completely new to MVC forum. I have a list like this.
public class DomainList
{
public string Domain { get; set; }
}
var DomainList = new List<DomainList>();
Now using foreach loop I am adding string value into this list.
var DomainList = new List<DomainList>();
DirectoryEntry en = new DirectoryEntry();
// Search for objectCategory type "Domain"
DirectorySearcher srch = new DirectorySearcher(en, "objectCategory=Domain");
SearchResultCollection coll = srch.FindAll();
// Enumerate over each returned domain.
foreach (SearchResult rs in coll)
{
ResultPropertyCollection resultPropColl = rs.Properties;
foreach (object domainName in resultPropColl["name"])
{
DomainList.Add(new DomainList { Domain = "LDAP://" + domainName.ToString() });
} }
}
This list (DomainList) I want to bind with the dropdown. How can I achieve this?
Doing this with a simple table (which looks like a GridView is very simple, which I am able to achieve using this code.
Member
63 Points
204 Posts
DropDownList
Apr 22, 2015 07:08 AM|maverick786us|LINK
I am completely new to MVC forum. I have a list like this.
Now using foreach loop I am adding string value into this list.
This list (DomainList) I want to bind with the dropdown. How can I achieve this?
Doing this with a simple table (which looks like a GridView is very simple, which I am able to achieve using this code.
How can I achieve the same thing with a dropdownlist, just like the way I did with a simple Tr Td in the above example??