Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

my program contains data which displayed in gridview.There's only one column. Ive need the data uniquely display which means no duplication allowed in the gridview. Anyone can help me?

here is my code:
C#
private void displaystring id)
      {

                  dataGridView1.Rows.Add(id);

      }


Please help me....
Posted

1 solution

You can handle the duplication at various levels:
1. UI level - Check using javascript that the value of the column that needs to be unique is not duplicating when entered new or updated old

2. Business logic level - check the value being updated/inserted for duplication. Loop through all the values and return true or false based on it. Accordingly execute the updation/insertion

3. Database - set a unique constraint to the field that you are avoiding to be duplicate. If it happens, it wont allow to be inserted and an error specific to it can be caught and treated accordingly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900