Hi,
I'm developing user page where he can view his uploaded files. I'm using LINQ and ADO.NET entity framework.
In the aspx page I have Listview control and Entity data source. My ListView looks like:
HTML Code:
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" DataSourceID="EntityDataSource1" ItemType="MyWebsiteModel.Image">
<ItemTemplate>
<li>
Upload date:
<asp:Label ID="CreateDateTimeLabel" runat="server" Text='<%# Item.CreateDateTime %>' />
<br />
Category:
<asp:Label ID="CategoryLabel" runat="server" Text='<%# CategoryName %>' />
<br />
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
</li>
</ItemTemplate>
</asp:ListView>
For example in code behind I'm having a code:
Code:
using (MyWebsiteEntities1 Entities = new MyWebsiteEntities1())
{
MyWebsiteModel.Image myImage = (MyWebsiteModel.Image)e.Entity;
var Name = from category in Entities.Categories
where category.Id == myImage.CategoryId
select category.Name;
string CategoryName = Name.Single();
}
So as you see in code behind I have variable CategoryName. How can I show the value of this variable on this label:
<asp:Label ID="CategoryLabel" runat="server" Text='<%# CategoryName %>' />