RepositoryASP.NET MVC CheckBoxes Problème
MvcApplication1.Models espace de noms { public class GroupRepository { EgovtDataContext db = new EgovtDataContext();
public IQueryable<Group> FindAllGroups()
{
return db.Groups;
}
public IQueryable<Group> FindGroups()
{
return from Group in FindAllGroups()
orderby Group
select Group;
}
public Group GetGroups(int id)
{
return db.Groups.SingleOrDefault(d => d.int_GroupId == id);
}
//
public void Add(Group group)
{
db.Groups.InsertOnSubmit(group);
}
public void Delete(Group group)
{
db.Groups.DeleteOnSubmit(group);
}
//
// Persistence
public void Save()
{
db.SubmitChanges();
}
}
}
CONTRÔLEUR
public ActionResult Index()
{
GroupRepository grouprepository = new GroupRepository();
ViewData["Group"] = grouprepository.FindGroups();
return View();
}
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage" %>
<% foreach (Group i in ViewData["Group"] as List<Group>)
{ %>
<input type="checkbox" name="Inhoud"
value="<%= i.int_GroupId %>" checked="checked" />
<% } %>
La chose est qu'il ne peut pas trouver l'identifiant de groupe et d'afficher l'erreur suivante. Quelle est la solution?
CS1061: 'System.Text.RegularExpressions.Group' does not contain a definition for 'int_GroupId' and no extension method 'int_GroupId' accepting a first argument of type 'System.Text.RegularExpressions.Group' could be found (are you missing a using directive or an assembly reference?)
Que FindGroups() renvoie-t-il? Y a-t-il du html manquant? – hunter
public IQueryable FindGroups() { retour de Group dans FindAllGroups() par groupe select Groupe; } –
maztt
Quel est l'espace de noms de Group? Je suppose que ce n'est pas 'System.Text.RegularExpressions.Group' – hunter