Questions:
I'm trying to do something that should be simple but does not appear to be in practise.
I have a simple sharepoint list. I added 4 entries, one of the columns is "Country"
Next, I created an aspx page in Sharepoint Designer to display the values in a table.
I added a DataSource based on the list and then a drop down control, populating it with the "Country" values... however I can not get rid of the non-unique values.
This was to be my Country Filter
I have 4 items, 3 have Ireland, 1 have the UK, I get 3 Irelands and a UK in my list. While you can sort the values, there does not appear to be anyway to tell sharepoint to just display distinct values.
If this was asp.net and a sql server you would simply do a "select distinct... " query.
string
siteUrl = "http://" + Request.Url.Host + ":" + Request.Url.Port + "/" + _lang + "/";
SPSite spSiteCollection = new SPSite(siteUrl);
SPWeb currentWeb = spSiteCollection.RootWeb;
SPListcurrentList=this.CurrentWeb.Lists[this.ListName]; |
SPFieldCollectionlistFields=currentList.Fields; |
SortedListslSortedList=newSortedList(); |
foreach(SPFieldfieldinlistFields) |
{ |
if(field.Sortable&&!field.Hidden) |
{ |
if(!slSortedList.ContainsKey(field.Title)) |
{ |
slSortedList.Add(field.Title,field.InternalName); |
} |
} |
} |
ddlSRSortField1.DataSource=slSortedList; |
ddlSRSortField1.DataTextField="Key"; |
ddlSRSortField1.DataValueField="Value"; |
ddlSRSortField1.DataBind();
I tried using CAML Query...here using Datatable distinct list items were selected. public DataView DistinctProjectItem(string listName,string fieldName) DataTable dtDistinctProject = spListItem.GetDataTable(); try reference:
|