KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to optimize the code for SharePoint webpart. I have a repeater control: <asp:Repeater ID="CountryOptionsRepeater" runat="server"> <ItemTemplate> <option value='<%#Eval("CountryName") %>'><%#Eval("CountryName") %></option> </ItemTemplate> </asp:Repeater> I am filling it with data-table countriesList = countriesList.Distinct<String>().ToList<String>(); countriesList.Sort(); //var noDupsCountriesList = new HashSet<String>(countriesList); DataTable dt = new DataTable(); dt.Columns.Add("CountryName"); foreach (String countryName in countriesList) { DataRow dr = dt.NewRow(); dr["CountryName"] = countryName; dt.Rows.Add(dr); } CountryOptionsRepeater.DataSource = dt; CountryOptionsRepeater.DataBind(); this.DataBind(); Is there a way to directly bind HashSet object (noDupsCountriesList) to DataSource with same configuration of repeater, in order to bring about optimization? Something like: //countriesList = countriesList.Distinct<String>().ToList<String>(); //countriesList.Sort(); var noDupsCountriesList = new HashSet<String>(countriesList); CountryOptionsRepeater.DataMember = "CountryName"; // ?? CountryOptionsRepeater.DataSource = noDupsCountriesList; CountryOptionsRepeater.DataBind(); this.DataBind();
Tags (comma-separated)
Save Edits
Cancel