protected void myGridView_RowCreated(object sender, GridViewRowEventArgs e)
{
TableCellCollection tcHeader = e.Row.Cells;
TableCell newCell;
switch (e.Row.RowType)
{
case DataControlRowType.Header:
//第一行表头
newCell = new TableHeaderCell();
newCell.Text = "编号";
break;
case DataControlRowType.DataRow:
newCell = new TableCell();
newCell.Text = (e.Row.DataItemIndex + 1).ToString();
break;
default:
newCell = new TableCell();
break;
}
tcHeader.AddAt(0,newCell);
}
{
TableCellCollection tcHeader = e.Row.Cells;
TableCell newCell;
switch (e.Row.RowType)
{
case DataControlRowType.Header:
//第一行表头
newCell = new TableHeaderCell();
newCell.Text = "编号";
break;
case DataControlRowType.DataRow:
newCell = new TableCell();
newCell.Text = (e.Row.DataItemIndex + 1).ToString();
break;
default:
newCell = new TableCell();
break;
}
tcHeader.AddAt(0,newCell);
}