How to identify duplicate rows in data table in effective manner

Posted by Bhanubysani under ASP.NET on 1/6/2013 | Points: 10 | Views : 2329 | Status : [Member] | Replies : 2
Hi all,

I have a requirement,to hide duplicate records in grid view.my data table records will be like this.

Loan A/c No Name Date Deductions remarks
13221 Bhanu prakash 20-apr-2013 13409 EMI
13221 Bhanu Prkash 20-apr-2013 1456 Cheque bounce chr
13221 Bhanu prakash 20-apr 2013 123 miscllaneous

when i am binding this data table my requirement is hide 2nd row up to date column
if the same record repeats.

grid view look will be like this

Loan A/c No Name Date Deductions remarks
13221 Bhanu prakash 20-apr-2013 13409 EMI
1456 Cheque bounce chr
123 miscllaneous

Please help me in achieve this.here i specified only one record but in real data the rows will be multiple.

Thanks in advance.

Regards,

Bhanu Prakash

Regards,
Bhanu Prakash Bysani



Responses

Posted by: Shubham on: 1/7/2013 [Member] Starter | Points: 25

Up
0
Down
hi!!! Bhanubysani
you can use
The DISTINCT keyword can be used to return only distinct (different) values.
SQL SELECT DISTINCT Syntax
**********************************************************************************************************
SELECT DISTINCT column_name(s)
FROM table_name

it will show only unique column no repeted

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Bhanubysani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Peermohamedmydeen on: 1/7/2013 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Before binding the datatable into grid, you have to play with the the datatable to get the desired.

Have a temporary datatable and you can filter the data something like,

DataView view = new DataView(table);

DataTable distinctValues = view.ToTable(true, "Column1", "Column2" ...);


and merge into your final datatable. Now bind it.

Thanks
PMM


Bhanubysani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response