private void MyDataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemIndex!=-1)
{
int aa=e.Item.ItemIndex+1;
e.Item.Cells[0].Text =aa.ToString();
}
}

解决方案 »

  1.   

    private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    int row =0; 
    int y = 0;
    string text="";
    e.Graphics.DrawString("序号",this.dataGrid1 .Font, new SolidBrush(Color.Black), 4, this.dataGrid1.Top -10); 
    for(int i =0;i<this.ds.Tables[0].Rows.Count;i++)
    {
    text =" " + (row+1);
    y=this.dataGrid1.GetCellBounds(row, 0).Y +2;
    e.Graphics.DrawString(text,this.dataGrid1.Font, new SolidBrush(Color.Black), 4, y); 
    row++;
    }

    }
      

  2.   

    其实仅在 html 设置列属性就可以了,我忘记了,up