1.后台
GridView1.DataSource = dt;
GridView1.DataBind();
if (dt != null && dt.Rows.Count > 0)
{
#region 设置gridview1标题行的style
GridView1.Attributes.Add("style", "border:none");
GridViewRow gvr = GridView1.HeaderRow;
for (int i = 0; i < gvr.Cells.Count; i++)
{
gvr.Cells[i].Attributes.Add("style","border:none");
}
#endregion
}//if
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridView1.Rows[i].Cells[0].Attributes.Add("align", "center");
GridView1.Rows[i].Cells[0].Attributes.Add("style", "border:none");
.................
}
2.JS动态新加的行
//添加新行
gridview1.setAttribute("style","border:none");
var newRow=gridview1.insertRow();
newRow.setAttribute("style","border:none");
var newCell1=newRow.insertCell();
var rowsCount=gridview1.rows.length;
newCell1.innerHTML=rowsCount-1;//第一列;加完新行并除去表头
newCell1.align="middle";
newCell1.setAttribute("style","border:none");
........................
3.页面中的GridView1(GridLines="None"必要,否则在FireFox中仍然显示网格线)
<asp:GridView ID="GridView1" runat="server" CssClass="css1" AlternatingRowStyle-BackColor="#F5F5F5"
GridLines="None">