Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2016, 04:12 PM
Registered User
 
Join Date: Dec 2015
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Post Chapter 14 - Inserting & Deleting Data with ListView Control

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.
 
Old May 31st, 2016, 09:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I don't see this code touching any files so I can't explain where this error is coming from. What is in "'file directory emitted"?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14: Inserting and Deleting Data with the ListView Control phztfte1 BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 3 January 18th, 2016 04:31 PM
Chapter 14 Inserting and Deleting Data with the ListView Control winkimjr2 BOOK: Beginning ASP.NET 4 : in C# and VB 11 May 18th, 2013 07:29 AM
Chapter 14 errors for Inserting and Deleting Data with the ListView Control winkimjr2 BOOK: Beginning ASP.NET 4 : in C# and VB 7 May 15th, 2013 02:28 PM
Chapter 14 Customizing Templates of the ListView Control rmanapul BOOK: Beginning ASP.NET 4 : in C# and VB 7 May 21st, 2012 04:42 AM
Chapter 14, Listview control problem SamuelMSr BOOK: Beginning ASP.NET 4 : in C# and VB 3 September 28th, 2011 02:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.