这是我尝试过但我为job_Name
获取null GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
int RowIndex = row.RowIndex; // this find the index of row
string job_Name = row.Cells[1].Text;
job_Name
是null
。
答案 0 :(得分:0)
尝试这种方式:
private void RowCommand(object sender, GridViewCommandEventArgs e)
{
var grid = sender as GridView;
if (grid == null)
{
return;
}
var index = Convert.ToInt32(e.CommandArgument);
var row = grid.Rows[index];
string job_Name = row.Cells[1].Text;
}