2016-02-12 43 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