我想改变那些值的颜色,让我们说0将是绿色1蓝色2红色。
solrconfig.xml
如果我需要更具体,请告诉我,我不是专业人士。我不知道在哪里可以控制细胞。 我还想在文本上添加鼠标(因此它将显示当前值的出现日期)。 也许一些函数/ javascript ...?
答案 0 :(得分:0)
您可以使用带有 OnRowDataBound 属性的gridview控件将特定属性绑定到每个单元格/行。
答案 1 :(得分:0)
使用OnRowDataBound
gridview事件,这里是示例
protected void GridCompany_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (GridViewRow gridViewRow in GridCompany.Rows)
{
if (gridViewRow.RowType == DataControlRowType.DataRow)
{
if (gridViewRow.Cells[6].Text.ToUpper() == "TRUE")// find your cell value and check for condition
{
// put here your logic
}
else
{
// put here your Else logic
}
}
}
}
答案 2 :(得分:0)
使用jQuery非常简单轻量级的解决方案:
代码背后:
set
<强> .ASPX:强>
public partial class GridViewCellColourChange : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
gvItems.DataSource = this.GetData();
gvItems.DataBind();
}
}
private IEnumerable<Item> GetData()
{
var item1 = new Item { item = "itm1", prop1 = "23", prop2 = "asd", prop3 = "23d", values = "0-0-0-0-0" };
var item2 = new Item { item = "itm2", prop1 = "43", prop2 = "asd", prop3 = "23d", values = "0-0-0-0-0" };
var item3 = new Item { item = "itm3", prop1 = "53", prop2 = "asd", prop3 = "23d", values = "0-0-0-0-0" };
return new List<Item> { item1, item2, item3 };
}
}
public class Item
{
public string item { get; set; }
public string prop1 { get; set; }
public string prop2 { get; set; }
public string prop3 { get; set; }
public string values { get; set; }
}
<强>输出:强>