Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
I newly joined as Asp.Net Developer.
I have one Question.
I have to bind Database Record to DropDown Without Duplicate Entries
Please Help Me.
public void BindPrjNmToDrpDwn()
{ 
    int EmplId = Convert.ToInt32(Session["UserID"]);
    var PrjNm = (from table2 in objPms.PM_TaskDetails
                 join tabPrj in objPms.PM_ProjectDetails on table2.Proj_Id equals tabPrj.Project_ID
                 where table2.AssignedBy == Convert.ToString(EmplId)
                 select tabPrj.Proj_Title);
    ddlAllProject.DataSource = PrjNm;
    ddlAllProject.DataBind();
Posted
Updated 24-Nov-10 18:39pm
v2
Comments
Tarun.K.S 25-Nov-10 0:54am    
you have to use the distinct keyword in your SQL Query.

1 solution

Add distinct in the end,
SQL
var PrjNm = (from table2 in objPms.PM_TaskDetails
                 join tabPrj in objPms.PM_ProjectDetails on table2.Proj_Id equals tabPrj.Project_ID
                 where table2.AssignedBy == Convert.ToString(EmplId)
                 select tabPrj.Proj_Title distinct);
 
Share this answer
 
Comments
Tarun.K.S 27-Nov-10 12:19pm    
Perfect!

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