Hi Imar,
After completing this "Try It Out" I get a an error that says "The process cannot access the file 'file directory emitted' because it is being used by another process." I have Googled the error and it sounds as if my code is being read twice. I have made some amendments to make it relevant to my project so that may be an issue itself?
This is my ManagePhotos.aspx.cs (ManageTeam.aspx.cs in my project):
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.ModelBinding;
public partial class Manager_ManageTeam : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
// The return type can be changed to IEnumerable, however to support
// paging and sorting, the following parameters must be added:
// int maximumRows
// int startRowIndex
// out int totalRowCount
// string sortByExpression
public IQueryable ListView1_GetData([QueryString("TeamId")] int teamId)
{
var myEntities = new TikitakaEntities();
return from p in myEntities.TeamImages
where p.TeamId == teamId
select p;
}
public void ListView1_InsertItem([QueryString("TeamId")] int teamId)
{
TeamImage image = new TeamImage();
TryUpdateModel(image);
if (ModelState.IsValid)
{
using (var myEntities = new TikitakaEntities())
{
image.TeamId = teamId;
myEntities.TeamImages.Add(image);
myEntities.SaveChanges();
}
}
}
// The id parameter name should match the DataKeyNames value set on the control
public void ListView1_DeleteItem(int id)
{
}
}
Any help you can give is appreciated.