当GridView为自动生成的列时,GridView1.Columns.Count的值总是等于0。
此时,如果要获得GridView列数,可用GridView1.HeaderRow.Cells.Count。
同样,如要获得某一列的列名,可用GridView1.HeaderRow.Cells[i].text(其中“i”为列的索引值)。