I am retrieving a string value (domain list) from an HTTP service, I want the values (DomainName: Status) to bind to a repeater where I have separate labels to display the values.
Domain Name Status
Here I separate the various domains from each other:
foreach(var dom in
_response.Split(domainList, StringSplitOptions.RemoveEmptyEntries))
Now I have the string value: domainname:status
Here I separate these:
var val = dom.Split(seperation).Select(v => v.Trim()).ToList();
Now I have a class with 2 different properties… Domainname and Status..
Here I add these values to a class of this kind:
_searchResult.DomainName = val[0];
_searchResult.Status = val[1];
Here I add this class to List<DomainClass> : _domainItem.Add(_searchResult);
and then I bind this List to repeater:
rptDomainList.DataSource = _domainItem;
rptDomainList.DataBind();
The result is a list of domains, or should I say a Domain. I get a list of 10 domains with the same extension..
Where am I going wrong?
Looks like you are not creating a new instance for
_searchResulteach time you are processing a new domainList item, am I right? Basically you should do_searchResult = new ...for each loop cycle otherwise you owerwriting previous values each new loop cycle because working with single instance (_searchResult) so final list will contains multiple searchResults with the same values (of latest domainList item)