<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
using (MvcApplication1.Models.EgovtDataContext _model = new MvcApplication1.Models.EgovtDataContext())
{
%>
<% foreach(var md in MvcApplication1.Models.) { %>
<% if (md.ParentId == 0)
{ %>
<% } %>
<% } %>
<%} %>
FeatureRepository類
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Models
{
public class FeaturesRepository
{
EgovtDataContext db = new EgovtDataContext();
public IEnumerable<Feature> GetAllFeatures()
{
List<Feature> Features = new List<Feature>();
Feature feature = new Feature();
var AllParentFeatures = FeaturesByParentId(0);
foreach (Feature frParentCategory in AllParentFeatures)
{
feature.int_FeatureId = frParentCategory.int_FeatureId;
feature.vcr_FeaturesName = frParentCategory.vcr_FeaturesName;
feature.int_ParentId = frParentCategory.int_ParentId;
Features.Add(feature);
var AllChildFeaturesofthatParent = FeaturesByParentId(frParentCategory.int_FeatureId);
int AllChildFeaturesofthatParentCount = AllChildFeaturesofthatParent.Count();
foreach (Feature frChildCategory in AllChildFeaturesofthatParent)
{
feature.int_FeatureId = frParentCategory.int_FeatureId;
feature.vcr_FeaturesName = frParentCategory.vcr_FeaturesName;
feature.int_ParentId = frParentCategory.int_ParentId;
Features.Add(feature);
}
}
return Features;
}
}
}
1)此正確地進行公開的IEnumerable GetAllFeatures()在上面的方法?,並且該方法正確地寫入? 2)我想調用上面的控件中的GetAllFeatures方法?我會怎麼做? 3)用戶控制器應該在共享文件夾中創建?什麼是共享文件夾?
用戶控制器應共享文件夾中創建? – maztt 2010-05-10 19:45:05
您可以在控制器文件夾中創建控制器 – Pinu 2010-05-10 19:53:12