1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

problem on asp.net

Discussion in 'C#' started by alanX, Jun 26, 2006.

  1. #1
    Hi all,
    i have a problem like that;
    table1
    PortNo Supplier ...
    1 -------s1
    2 -------s1
    3 -------s2
    4 -------s3
    5 -------s4
    6 -------s5
    SEMrush
    when i use DropdownList to hold the DataTextField "Supplier", it always shows all the data in the DropdownList,including "Duplicate s1".

    but i don't want to show the s1 twice in the DropdownList. How can i achieve that?

    code: DropDownList1.DataSource = ds.Tables["Table1"].DefaultView;
    DropDownList1.DataTextField = "Supplier";
     
    alanX, Jun 26, 2006 IP
    SEMrush
  2. hcole

    hcole Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When setting up the SQL for the datasource, use the distinct keyword :
    Select distinct supplier from Table1
     
    hcole, Jul 1, 2006 IP
  3. DanInManchester

    DanInManchester Active Member

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    surely supplier is normalised out into another table?
    If so setup another datasource to populate your list.
     
    DanInManchester, Jul 5, 2006 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,607
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    maybe you should clean out your table? Distinct is an extra step to the processor, especially when it's not needed. Create a new table, copy over the data using DISTINCT, then bring it back to clean out dupes. Then you can do a straight up Select.
     
    ccoonen, Jul 10, 2006 IP