Gridview Duplicate removal.

Discussion in 'ASP .Net' started by Guest, Feb 7, 2006.

  1. Guest

    Guest Guest

    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
     
    Guest, Feb 7, 2006
    #1
    1. Advertising

  2. Guest

    Guest Guest

    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
    >
     
    Guest, Feb 7, 2006
    #2
    1. Advertising

  3. Guest

    Guest Guest

    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
    >>

    >
    >
     
    Guest, Feb 7, 2006
    #3
  4. 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
     
    Yuan Ren[MSFT], Feb 8, 2006
    #4
  5. Guest

    Guest Guest

    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]"" <> 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
    >
     
    Guest, Feb 8, 2006
    #5
  6. 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
     
    Yuan Ren[MSFT], Feb 9, 2006
    #6
  7. Guest

    Guest Guest

    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]"" <> 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
    >
     
    Guest, Feb 9, 2006
    #7
  8. 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
     
    Yuan Ren[MSFT], Feb 13, 2006
    #8
  9. Guest

    Guest Guest

    Yuan,

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

    Thanks again!

    J

    ""Yuan Ren[MSFT]"" <> 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
    >
     
    Guest, Feb 14, 2006
    #9
  10. 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
     
    Yuan Ren[MSFT], Feb 14, 2006
    #10
  11. Guest

    Bill Gregg Guest

    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 ***
     
    Bill Gregg, Feb 14, 2006
    #11
  12. Guest

    Guest Guest

    Can you show an example of that Bill?

    J

    "Bill Gregg" <> wrote in message
    news:...
    >
    > 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 ***
     
    Guest, Feb 14, 2006
    #12
  13. 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
     
    Yuan Ren[MSFT], Feb 15, 2006
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SGF3aw==?=
    Replies:
    0
    Views:
    518
    =?Utf-8?B?SGF3aw==?=
    Feb 21, 2007
  2. raja

    Duplicate removal

    raja, Feb 4, 2006, in forum: C Programming
    Replies:
    5
    Views:
    344
    Arndt Jonasson
    Feb 7, 2006
  3. Sunny
    Replies:
    0
    Views:
    199
    Sunny
    Jul 14, 2006
  4. David Thielen

    Can't duplicate ID in subclassed GridView

    David Thielen, Oct 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    162
    Walter Wang [MSFT]
    Oct 27, 2006
  5. David Unric
    Replies:
    14
    Views:
    319
    Robert Klemme
    Mar 18, 2011
Loading...

Share This Page