Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my Dropdown im trying to Display all the news from a specific Department

I have Departments with different ids in the database ...........



XML
public List<New>  getNewsType()
    {
        NewsDataContext objNews = new NewsDataContext(); // new instance of class


      var allNews=  objNews.News.GroupBy(x => x.Department).Select(x => x.SingleOrDefault());

      return allNews.ToList();


  private void bindNews()
    {
        linqClass objLinq = new linqClass();

        ListView1.DataSource = objLinq.getNewsType();
        ListView1.DataBind();
        ddl_news.DataSource = objLinq.getNews();
        ddl_news.DataTextField = "Department";
        ddl_news.DataValueField = "Department";
        ddl_news.DataBind();
    }
Posted
Comments
Herman<T>.Instance 11-Apr-14 14:07pm    
And now the question?

1 solution

XML
ICollection<ServiceContract> serviceContract = mapper.MapDALServiceContracts2BAL(objDalServiceContract.getAllServiceContract());
           if (id > 0)
           {

             var sc = serviceContract.GroupBy(m => m.EndDate).Select(g => g.First());

           }



For more details visit on below link.
http://www.code-sample.com/2014/06/distinct-values-from-list-using-linq.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900