我有一个页面在几个数据网格中使用大型过滤的EF对象,因此每个数据网格显示不同的“状态”。页面代码有点失控,所以我想将这些部分分成用户控件。我只想获取一次数据,所以我希望能够将正确过滤的数据对象列表传递给适当的用户控件。我只是不确定如何去做。有什么建议吗?
谢谢,
朗达
我的数据对象
activeDisplayChecklist = allDisplayChecklist.Where(x => x.ChecklistStatus.ToString().ToUpper() != Checklist.ChecklistStatus.Approved.ToDescriptionString().ToUpper() && x.ChecklistStatus.ToString().ToUpper() != Checklist.ChecklistStatus.Canceled.ToDescriptionString().ToUpper()).ToList();
Workqueue.ascx.cs
public partial class WorkQueue : System.Web.UI.UserControl
{
public List<Entities.Checklist> activeChecklists { get; set; }
private List<AMWOTPortalDisplay> ActiveDisplayChecklist = new List<AMWOTPortalDisplay>();
public List<AMWOTPortalDisplay> activeDisplayChecklist
{
get
{
return ActiveDisplayChecklist;
}
set
{
ActiveDisplayChecklist = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
PopulateWorkQueueGrid();
}
//show statuses that require approval (Submitted or CTO Exception)
//public void PopulateWorkQueueGrid(List<AMWOTPortalDisplay> ActiveDisplayChecklist)
public void PopulateWorkQueueGrid()
{
// ActiveDisplayChecklist总是Count = 0或null List filteredChecklist = ActiveDisplayChecklist.Where(x =&gt; x.ChecklistStatus.ToString()。ToUpper()== Checklist.ChecklistStatus.Submitted.ToDescriptionString()。ToUpper()|| x.ChecklistStatus.ToString()。ToUpper() == Checklist.ChecklistStatus.CTOException.ToDescriptionString()。ToUpper())。ToList(); WorkQueueGrid.DataSource = filteredChecklist.ToList(); WorkQueueGrid.DataBind(); } }
<WQ:WorkQueueList ID="WorkQueueList" runat="Server"></WQ:WorkQueueList>
portal.aspx.cs(这里的对象包含9行和12行)
WorkQueue wq = new WorkQueue();
wq.activeChecklists = activeChecklists.ToList();
wq.activeDisplayChecklist = activeDisplayChecklist.ToList();