Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Manual CRUD not deleting and updating
posted

Am a new budding programmer. Am learning from your tutorials. There in the video 'WebDataGrid AutoCrud_ ASP.NET Data Grid Control'

public class PersonRepository

{

private IList<Person> _people = new List<Person>();

public PersonRepository()

{

this.InitializeData();

}

public void Insert(Person person)

{

this._people.Add(person);

}

private void InitializeData()

{

_people.Add(new Person()

{

FirstName = "Otto",

SecondName = "Parts",

LastLoginDate = new DateTime(2009, 4, 3),

PersonTypeId = 1,

PersonTypeTitle = "Expert User",

Id = 1

});

_people.Add(new Person()

{

FirstName = "Gym",

SecondName = "Nasium",

LastLoginDate = new DateTime(2010, 5, 3),

PersonTypeId = 1,

PersonTypeTitle = "Super User",

Id = 2

});

_people.Add(new Person()

{

FirstName = "Nara",

SecondName = "Simha",

LastLoginDate = new DateTime(2009, 5, 3),

PersonTypeId = 2,

PersonTypeTitle = "Poor User",

Id = 3

});

_people.Add(new Person()

{

FirstName = "Kizhakkan",

SecondName = "Pathros",

LastLoginDate = new DateTime(2012, 5, 4),

PersonTypeId = 2,

PersonTypeTitle = "Descent User",

Id = 4

});

 

}

public IList<Person> GetAll()

{

return this._people;

}

public void Delete(Person person)

{

for (int i = 0; i < this._people.Count - 1; i++)

{

if (this._people[i].Id == person.Id)

{

this._people.Remove(this._people[i]);

}

}

}

public void Delete(int Id)

{

for (int i = 0; i < this._people.Count - 1; i++)

{

if (this._people[i].Id == Id)

{

this._people.Remove(this._people[i]);

}

}

}

public void Update(Person person)

{

for (int i = 0; i < this._people.Count - 1; i++)

{

if (this._people[i].Id == person.Id)

{

this._people.Remove(this._people[i]);

this._people.Insert(i, person);

}

}

}

}

------------------------------

public partial class Web1 : System.Web.UI.Page

{

 

//protected void Page_Load(object sender, EventArgs e)

//{

//}

private PersonRepository Repository

{

get

{

if (this._repository == null)

{

return new WebStateRepository<PersonRepository>().Instance;

 

}

return this._repository;

}

}

private PersonRepository _repository = null;

 

 

 

 

protected void ods_ObjectCreating(object sender, ObjectDataSourceEventArgs e)

{

e.ObjectInstance = this.Repository;

}

}

-----------------------------

how

return new WebStateRepository<PersonRepository>().Instance;

can be done? am not able to move from this point. Kindly help

Parents
No Data
Reply Children