网格视图具有行跨度时的网格视图的替代颜色 [英] alternate color for grid view when gird view having row span
问题描述
你好我有一行和3列的网格视图。前两个是原样,第三列是基于结果集的列跨度
ex
ID 类别 子类别
1销售jan
2月
march
2生产Jan
2月
3发布jan
所以我使用下面的代码替代颜色,但子类别明智的替代颜色来。
i需要替代颜色基于ID和类别而不是子类别。
你能为此提供解决方案。
Hello i have grid view in that for one row and 3 columns. first two is as it is and 3rd column having column-span based on result set
ex
ID category sub category
1 sales jan
Feb
march
2 production Jan
Feb
3 release jan
so i am using below code for alternative color but sub category wise alternative color comming .
i need alternative color base on ID and category not sub category.
Can you provide solution for this.
AlternatingRowStyle-CssClass="alt"
和
.Grid .alt
{
background:#DEEDF5;
}
推荐答案
尝试
GridView.RowDatabound事件
http://msdn.microsoft.com/en-us/library/aa479342.aspx
GridView.RowCreated事件
http://msdn.microsoft.com/en-us/library/system .web.ui.webcontrols.gridview.rowcreated%28v = vs.110%29.aspx
Try
GridView.RowDatabound event
http://msdn.microsoft.com/en-us/library/aa479342.aspx
GridView.RowCreated event
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcreated%28v=vs.110%29.aspx
void productsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int ID= Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,"ID"));
string strCategory= Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,"Category"));
if (ID== 1 && strCategory == "sales")
e.Row.BackColor = Color.Yellow;
else if(ID== 2 && strCategory == "production")
e.Row.BackColor = Color.Gray;
}
}
这篇关于网格视图具有行跨度时的网格视图的替代颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!