Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Gridview Duplicate removal.

 
Thread Tools Search this Thread
Old 02-07-2006, 03:32 PM   #1
Default Gridview Duplicate removal.


Hello,

How would I remove duplicate rows from a dataset after it has already been
populated?

What would be the best way to check each row and delete duplicates while
leaving at least one unique of the duplicate rows?

Any Ideas?

Thanks in advance,

J




  Reply With Quote
Old 02-07-2006, 03:36 PM   #2
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Oops,

My subject was probably misleading. Let me clarify.

My gridview in my asp.net 2.0 site is populated by a dataset not a
datasource.

Thanks,

j

<> wrote in message
news:...
> Hello,
>
> How would I remove duplicate rows from a dataset after it has already been
> populated?
>
> What would be the best way to check each row and delete duplicates while
> leaving at least one unique of the duplicate rows?
>
> Any Ideas?
>
> Thanks in advance,
>
> J
>



  Reply With Quote
Old 02-07-2006, 10:26 PM   #3
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Does anyone have any idea on how I should do this?

J

<> wrote in message
news:...
> Oops,
>
> My subject was probably misleading. Let me clarify.
>
> My gridview in my asp.net 2.0 site is populated by a dataset not a
> datasource.
>
> Thanks,
>
> j
>
> <> wrote in message
> news:...
>> Hello,
>>
>> How would I remove duplicate rows from a dataset after it has already
>> been populated?
>>
>> What would be the best way to check each row and delete duplicates while
>> leaving at least one unique of the duplicate rows?
>>
>> Any Ideas?
>>
>> Thanks in advance,
>>
>> J
>>

>
>



  Reply With Quote
Old 02-08-2006, 05:23 AM   #4
Yuan Ren[MSFT]
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Hi J,

Thanks for posting!

For the current issue, I wonder the duplicated row is encountered in the
data base layer or the dataset layer?

In the dataset layer, there is not existed method to delete the duplicated
row. Since there are many duplicated rows such like duplicated primary key,
or duplicated one column, I think you can write your own method to
implement it in the dataset layer.

Thanks for your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

  Reply With Quote
Old 02-08-2006, 08:41 AM   #5
 
Posts: n/a
Default Re: Gridview Duplicate removal.

The data that I bring into the dataset is from two tables in my sql database
and it's a many to many relationship. I use an sql join statement and when
I do I end up with the following:

(PartNumber Column)
10024
10024
10024
10025
10025
10067
10067
10067

What I want it to look like is this:

10024
10025
10067

I am not familiar enough with SQL statements to fix this problem in the sql
join statement so I figured I could just remove the extra rows after the
fact in either the dataset or the Gridview.

Thanks,

J


""Yuan Ren[MSFT]"" <v-> wrote in message
news:...
> Hi J,
>
> Thanks for posting!
>
> For the current issue, I wonder the duplicated row is encountered in the
> data base layer or the dataset layer?
>
> In the dataset layer, there is not existed method to delete the duplicated
> row. Since there are many duplicated rows such like duplicated primary
> key,
> or duplicated one column, I think you can write your own method to
> implement it in the dataset layer.
>
> Thanks for your understanding!
>
> Regards,
>
> Yuan Ren [MSFT]
> Microsoft Online Support
>



  Reply With Quote
Old 02-09-2006, 08:25 AM   #6
Yuan Ren[MSFT]
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Hi J,

Thanks for your reply!

As I replied in the pervious thread, you need write your own method for
deleting the duplicated row. For example, you can read the row from the
current dataset. Then, you judge whether the next row is duplicated with
the current. If this is true, you get rid of the current row and read the
next. After this judgment, you can put the data to a new dataset and bind
the dataset with the GridView control.

Thanks for your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

  Reply With Quote
Old 02-09-2006, 09:37 PM   #7
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Oh, I get it. That makes perfect sense. I did not gather that from your
last post but I understand clearly now.

Will that way of doing it be the least processor intensive?
In some instances there could be over 10,000 or more rows.

I wish I was more familiar with SQL Statements because I am sure that all
this could be done before hand when the data is called from the database. I
just dont understand how to do that.

I will definantly try the two dataset approach and let you know how that
works out.

Regards,

J

""Yuan Ren[MSFT]"" <v-> wrote in message
news:...
> Hi J,
>
> Thanks for your reply!
>
> As I replied in the pervious thread, you need write your own method for
> deleting the duplicated row. For example, you can read the row from the
> current dataset. Then, you judge whether the next row is duplicated with
> the current. If this is true, you get rid of the current row and read the
> next. After this judgment, you can put the data to a new dataset and bind
> the dataset with the GridView control.
>
> Thanks for your understanding!
>
> Regards,
>
> Yuan Ren [MSFT]
> Microsoft Online Support
>



  Reply With Quote
Old 02-13-2006, 07:51 AM   #8
Yuan Ren[MSFT]
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Hi J,

Thanks for your reply!

>"Will that way of doing it be the least processor intensive?"

Unfortunately, I think the current method will take more time to execute
when there are more rows in the dataset. So, I think you can post a new
thread to the SQL newsgroup if you think the performance is the key point.
Thanks for your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

  Reply With Quote
Old 02-14-2006, 05:48 AM   #9
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Yuan,

Thanks for the response. I posted a thread there and am waiting on a
response.

Thanks again!

J

""Yuan Ren[MSFT]"" <v-> wrote in message
news:gAof$...
> Hi J,
>
> Thanks for your reply!
>
>>"Will that way of doing it be the least processor intensive?"

> Unfortunately, I think the current method will take more time to execute
> when there are more rows in the dataset. So, I think you can post a new
> thread to the SQL newsgroup if you think the performance is the key point.
> Thanks for your understanding!
>
> Regards,
>
> Yuan Ren [MSFT]
> Microsoft Online Support
>



  Reply With Quote
Old 02-14-2006, 08:35 AM   #10
Yuan Ren[MSFT]
 
Posts: n/a
Default Re: Gridview Duplicate removal.

Hi J,

You are welcome! If you have any further information related to this
problem, please feel free to post here. Thanks very much and looking
forward to hearing from you.

Yuan Ren [MSFT]
Microsoft Online Support

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump