你要先确定GridView1.DataKeys[e.RowIndex].Value.ToString是否获取值,然后试试这样写string sql = "delete from 用户表 where 用户名='" +GridView1.DataKeys[e.RowIndex].Value.ToString+ "'";