Gridview前面10行数据显示背景色,急急急 怎么样是gridview 前面10条数据具有背景色, 页面上显示的是25条数据?这个该怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $('tr :eq(9)').prev().css('background-color', 'red'); <%# Container.DataItemIndex<10 ? "" : "" %> 可以在RowDataBound事件中设定行的样式。 private void DataGrid1_PreRender(object sender, System.EventArgs e) { if(this.DataGrid1.Items.Count >=10){ for(int i=0;i<=10;i++){ this.DataGrid1.Items[i].BackColor = System.Drawing.Color.Red; } } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) {if(e.Row.RowIndex<=10){e.Row.BackColor = Color.Red;}}} Insus.NET习惯是写在OnRowCreated事件,而非onRowDataBound事件:http://www.cnblogs.com/insus/articles/2060705.html protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowIndex < 10) e.Row.Attributes.Add("style", "background:#000"); } } 1.$(function(){ $('tr gt(9)').addClass('红色背景样式名称');})2.可以利用这个Container.DataItemIndex<tr <%# Container.DataItemIndex < 10 ? "style=\'backgournd-color:red\'" : "" %> > ....</tr> $('tr:gt(9)').addClass('红色背景样式名称') --- 忘记下 ":" 了 在rowcreate事件里写 if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowIndex < 10) { e.Row.BackColor = Color.Red; } } oralce8换成10g后long字段读出来错误内容 在HTML中做一个判断,有高手进来吗 System.NullReferenceException: 未将对象引用设置到对象的实例。 已经混得倾家荡产了 一个页面调用另一页面中的方法问题? 求一个正则表达式写法,高人请进!!! 为什么我的label控件里的字怎么调,都把字的上半部分掩盖了 只显示下半部分 文件上传 这个算法怎么样写呀? VS.net编译的问题? 获取dropDownList选中值的问题【求助】 Web.Config.CookieConfig 这个怎么配置呢?
if(this.DataGrid1.Items.Count >=10){
for(int i=0;i<=10;i++){
this.DataGrid1.Items[i].BackColor = System.Drawing.Color.Red;
}
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.RowIndex<=10)
{
e.Row.BackColor = Color.Red;
}
}
}
http://www.cnblogs.com/insus/articles/2060705.html
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex < 10)
e.Row.Attributes.Add("style", "background:#000");
}
}
$(function(){
$('tr gt(9)').addClass('红色背景样式名称');
})2.
可以利用这个Container.DataItemIndex
<tr <%# Container.DataItemIndex < 10 ? "style=\'backgournd-color:red\'" : "" %> >
....
</tr>
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex < 10)
{
e.Row.BackColor = Color.Red;
}
}