Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello guys,am kind of new to the webmatrix environment,am trying to implement the use of object oriented programming in webmatrix.AM using the entity framework to handle saving records into my database.here is the problem am facing


I already have a class called Students defined as follows

C#
public class Student
{
    public int ID{get;set;}
    [Required]
    public string Student_number{get;set;}
    [Required(ErrorMessage="surname required")]
  public string Surname{get;set;}

    [Required (ErrorMessage="FirstName Required")]
    public string Firstname{get;set;}

    [Required(ErrorMessage="please enter your OtherNames")]
    public string Othername{get;set;}

    [Required(ErrorMessage="please enter your sex")]
     public string Sex{get;set;}}



i have a student Repository class which is making reference to my entity framework to insert the records into the database


public class EFRepository
{

private EFDBContext context = new EFDBContext();

public IQueryable<student> Student{ get { return context.Students;} }

public void Save(Student student){



context.Students.Add(student);
context.SaveChanges();
}

}

in my page where i want to implenment this class is where am having an issue..

if i hardcode the values into the instance of the new class Student,the records gets saved.


however since the form is going to be filled by the user,the textboxes has to be responsible for parsing the values being entered by the user into the student class.
but am confused on how to implement it.

any help would be appreciated..THANKS
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900