Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello
How do I repeat phrases when loading data from the database don't show to control of drop down list
plz help me
my code is
C#
var JensKakhat = db.ItemProducts.Where(c => c.ForProductId == DdlProduct.SelectedValue.ToString()).ToList();

int count3 = JensKakhat.Count();
if (count3 <= 0)
    PnlTypePaper.Visible = false;
else
    PnlTypePaper.Visible = true;

DdlTypePaper.DataSource = JensKakhat;
DdlTypePaper.DataTextField = "ItemNine";
DdlTypePaper.DataValueField = "Id";
DdlTypePaper.DataBind();
Posted
Updated 1-Nov-14 3:00am
v2
Comments
Afzaal Ahmad Zeeshan 1-Nov-14 8:44am    
What do you mean by repeating phrases?

Do you want to show some motto kinda thing in a label kinda thing while loading the data from the database? Sorry for kinda thing.
Member 11180545 1-Nov-14 8:59am    
should uses Distinct in lambda experession

1 solution

C#
var  result = JensKakhat.GroupBy(g => g.Id)
                         .Select(g => g.First())
                         .ToList();
PnlTypePaper.Visible = result.Any(); 

DdlTypePaper.DataSource = result;
DdlTypePaper.DataTextField = "ItemNine";
DdlTypePaper.DataValueField = "Id";
DdlTypePaper.DataBind();
 
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