Hi,
I have written a query to get result from table.
var queryres = (from r in objTestEntities.module_where r.PID ==id select r).ToList();
try
{
for (int j = 0; j < queryres.Count; j++)
{
string sModuleName = queryres[j].Title;
int iModuleId = queryres[j].ModuleID;
string sVersion = queryres[j].VersionNo;
sModuleNameList.Add(new SelectListItem
{
Text = sModuleName,
Value = iModuleId.ToString(),
Selected = true
});
sVersionList.Add(new SelectListItem
{
Text = sVersion,
Value = sVersion,
Selected = true
});
}
ViewData["Module"] = sModuleNameList;
ViewData["Version"] = sVersionList;
}
Now I want that sVersionList which is of type should have distinct value. But as from the queryres variable I am getting module name, and different module can have same version.
From above code in version list combo I am getting same version no multiple times.
But I want that one version should be seen only one time.
I have tried this also: ViewData["Version"] = sVersionList.Distinct(); But from this also I am not able to show the distict value in version list combo.