Hello,
PROBLEM: How to bind data to a label, without using a view control.
CONTEXT: Chp 14, on the "Manage Photo Album" page, I would like to place the Album title at the top of the page.
WHAT I DID: I use a panel and place a label inside so I can easily center the label. I use a LinQ query to get the Name of the Album. But I cannot bind the name to the label.
Code:
using (PlanetWroxEntities myAlbum = new PlanetWroxEntities())
{
var albumName = from m in myAlbum.PhotoAlbums
where m.Id == albumId // albumId retrieved from querystring
select new { m.Name };
THINGS I TRIED: I've tried using the Eval in the Markup View on the Label control and all sorts of scenarios. But I don't know if I'm assigning the datasource correctly, etc. I can get the Album name to display if I use view control (e.g., formview) at the top of the page and place a label inside. But I figured, there's probably just a simple way to bind data to a label without having to use a view control. Or must I use a view control of some sort?
Does anyone have an answer?