Distinct Selection Using Datatable and Repeater Control
Posted on 2009-06-29
Hello - thanks for taking a look at my ASP.NET question.
I have a datatable that contains three columns: ID, firstName, and lastName. I have a repeater control on my aspx page that is databound to this datatable and displays the firstName and lastName on the page.
The ID is not an auto-incremental primary key, rather the ID is pulled from another datasource related to the person's firstName and lastName.
Is there a way to prevent someone from adding the same record to the datatable? And, if not, a way to apply a Distinct Selection to the repeater?
For example, if I have a listing of names (showing the ID in this example)...
ID firstName lastName
1 John Smith
2 Jim Conner
3 Lisa Stanton
...is there a way to not allow the user to enter "John Smith" twice?
Would it be better for me to make the ID column a Primary Key? And, if so, how would I avoid the ASP.NET error page regarding unique constraints?
Thank you for any insight you might provide - I know I am asking a rather broad-based question.