473,408 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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
Feb 7 '06 #1
12 3687
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

<wa********@newsgroups.nospam> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl...
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

Feb 7 '06 #2
Does anyone have any idea on how I should do this?

J

<wa********@newsgroups.nospam> wrote in message
news:eN**************@TK2MSFTNGP15.phx.gbl...
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

<wa********@newsgroups.nospam> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl...
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


Feb 7 '06 #3
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

Feb 8 '06 #4
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-****@microsoft.com> wrote in message
news:cF**************@TK2MSFTNGXA01.phx.gbl...
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

Feb 8 '06 #5
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

Feb 9 '06 #6
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-****@microsoft.com> wrote in message
news:nR*************@TK2MSFTNGXA01.phx.gbl...
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

Feb 9 '06 #7
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

Feb 13 '06 #8
Yuan,

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

Thanks again!

J

""Yuan Ren[MSFT]"" <v-****@microsoft.com> wrote in message
news:gA*************@TK2MSFTNGXA01.phx.gbl...
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

Feb 14 '06 #9
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

Feb 14 '06 #10

Yuan,
You could put the keyword "distinct" after your select and before
your columns in your SQL statement. This will remove all the duplicated
rows.

Bill Gregg
*** Sent via Developersdex http://www.developersdex.com ***
Feb 14 '06 #11
Can you show an example of that Bill?

J

"Bill Gregg" <Ju**@Junk.net> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...

Yuan,
You could put the keyword "distinct" after your select and before
your columns in your SQL statement. This will remove all the duplicated
rows.

Bill Gregg
*** Sent via Developersdex http://www.developersdex.com ***

Feb 14 '06 #12
Hi J,

Thanks for your reply!

First of all, thanks for Bill's reminder. Since I don't use the SQL Server
with a long time, I forget there is the "distinct" keyword is more
appropriate at the current stage. For example, there is a table likes below:
num name
1 a
1 a
2 a
2 b
2 b

So, if you use the statement below:
select distinct * from tblduplicated

You will get the result:
1 a
2 a
2 b

Thanks for your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

Feb 15 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dave | last post by:
I am looking for some T_SQL code that would help us eliminate duplicate data entry into our mailing db. Finding and removing the existing dups is not rocket science, but I am looking for a complete...
9
by: vbportal | last post by:
Hi, I would like to add BitArrays to an ArrayList and then remove any duplicates - can someone please help me forward. I seem to have (at leaset ;-) )2 problems/lack of understanding (see test...
0
by: zerosleep | last post by:
I want to do this (some props removed intentionally): ..skin file: <asp:GridView SkinID="GridThemeA"> <RowStyle CssClass="someClass" /> <AlternatingRowStyle CssClass="someAltClass" />...
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
0
by: =?Utf-8?B?SGF3aw==?= | last post by:
Hello, I have the need to verifiy a field in a gridview for a duplicate value against a database before the update takes place. I was thinking that the gridview1.rowupdating would be a good place...
0
by: jrnail23 | last post by:
I have a user control which contains an UpdatePanel, which contains a MultiView inside, with a GridView in one of the views. In my GridView, I have a ButtonField which is supposed to trigger a...
10
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I understand how to connect a SqlDataSource to a GridView and have a nice data-connected, paginated web page generated with virtually no coding. Starting from that base, I would like to add an...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a gridview with 2 columns. One column is a BoundColumn to a part number (string). One column is an ItemTemplate with a FileUpload control. There can be multiple rows (i.e. part numbers)...
0
by: dotnetrookie | last post by:
Hi This is my 1st post.I have two checkbox columns in gridview binded through item template. The checkboxes are Category and Subcategory. I have actually removed the duplicate values in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.