JT_SIRO
asked on
How do I display unique items in Repeater?
I'm building a repeater, code listed below. How do I only show unique items in the list?
No code posted ;)
ASKER
oops
foreach (DataRow row in dt.Rows)
{
intCountBadCategories = intCountBadCategories + 1;
// Check to see if this is a valid category
if (IsValidCategory(row["Category"].ToString()) == false)
{
// Add to Repeater
DataRow newRow3 = dt3.NewRow();
newRow3["Category"] = row["Category"].ToString();
dt3.Rows.Add(newRow3);
}
}
If dt is populated from the database, the best place would be to use a SELECT DISTINCT in the code loading data into the datatable, dt.
otherwise, check if the value already exists in dt3. Something like:
if (IsValidCategory(row["Category"].ToString()) == false && dt3.Select("Category = '" + row["Category"].ToString().Replace("'","''") + "'").Length = 0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.