protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Attributes.Add("style", "border:1px solid #333333 ");
e.Row.Cells[1].Attributes.Add("style", "border:1px solid #333333 "); //#93c2f1;
e.Row.Cells[2].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[3].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[4].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[5].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[6].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[7].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[8].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[9].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[10].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[11].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[12].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[13].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[14].Attributes.Add("style", "border:1px solid #333333");
e.Row.Cells[15].Attributes.Add("style", "border:1px solid #333333");
}
}
gridview设置边框
本文介绍了一个简单的ASP.NET示例,展示了如何使用RowDataBound事件为GridView控件中的每一行设置统一的边框样式。通过遍历每行的单元格并添加自定义样式属性,可以实现网格视图中数据行的一致视觉效果。





