Linq – Remplir une liste déroulante (DropDownList)

var query = from m in data.menu
join p in data.page on m.menu_page_id equals p.id
group p by new { m.menu_txt , menuId = m.id, pid = p.id, } into g
select new { g.Key.menu_txt, g.Key.pid, g.Key.menuId };
int b = 0;
foreach (var i in query)
{
DropDownList1.Items.Add(i.menu_txt);
DropDownList1.Items[b].Value = i.menuId.ToString();
b++;
})

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s