none
distinct values in linq

    Question

  • I try linq query

    <asp:DropDownList ID="regiondrop" runat="server" AutoPostBack="True" 
    onselectedindexchanged="regiondrop_SelectedIndexChanged">
    </asp:DropDownList> 

    I try to show distinct values in drop-down on page load. I try this query to get values

    T1 tea = new T1();
    var list1 = tea.t1.ToList();
    var list = (from ta in list1
    orderby ta.Region
    select new { ta.Region,ta.RegionID }).Distinct().ToList();

    but this shows all same values where as i want distinct values

    update

    in my scenario data is

    RID  Region 
    1   Paris   
    2   Canada  
    3   UK  
    4   Paris   
    5   Canada 
    6   London

    so in this Canada and Paris 2 times so i want this 1 time in drop-down

    any solution?

    Wednesday, June 22, 2016 5:37 AM

Answers