2016-02-12 61 views
5

我正在使用实体框架的一个小项目,我目前正在学习ASPxGridView,但是,我似乎无法在互联网上找到任何与添加规则有关的内容然后根据规则集显示图标或突出显示行。ENTITY/LINQ/ASP.NET:ASPxGridView添加规则

事情是这样的:https://demos.devexpress.com/ASPxGridViewDemos/Rows/ConditionalFormatting.aspx

如果有人可以给我,他们可以发现可能有助于点我在正确的方向的任何引用,我们将不胜感激。

谢谢。

+1

如果你想这应该是相当straightforwards一个图标,你想有一个模板,这样就可以把逻辑展现图标。看看这里https://msdn.microsoft.com/en-gb/library/bb288032.aspx。由于您不控制td元素标记,因此着色单元格背景可能会更棘手。你可能更适合使用Repeater或ListView,因为它可以让你更好地控制标记。 – Mant101

回答

4

前端增加对实体框架ASPxGridView型号:

OnHtmlDataCellPrepared="ASPxGridView1_HtmlDataCellPrepared" 

后端补充:

// Add this in the Namespace area, not inside the Page_Load function 
public bool ProcessSelectionChangedOnServer { get; set; } 

protected void ASPxGridView1_HtmlDataCellPrepared(object sender, 
DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) 
{ 
    // if statements go here 
    e.Cell.BackColor = System.Drawing.Color.LightCyan; 
} 

码结果:

所有细胞背景颜色改变为LightCyan

参考文献:

ASPxGridView.HtmlRowPrepared Event
TreeListSettingsBehavior.ProcessSelectionChangedOnServer Property