比如某一列为int类型:
int k = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
if (i = 0) k = Convert.ToInt16(GridView1.Rows[i].Cells["XX"].Text);
if (k < Convert.ToInt16(GridView1.Rows[i].Cells["XX"].Text)) k = Convert.ToInt16(GridView1.Rows[i].Cells["XX"].Text);
}
k为最大
你的datagridview 有连接数据库吗