2017-06-01 37 views
0

的價值,這是我所嘗試,但我M代表JOB_NAME獲取一個GridView列的rowcommand

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_Namenull

回答

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; 
} 
+0

我米得到錯誤「」上變種指數= Convert.ToInt32(e.CommandArgument);「輸入字符串的不正確的格式。」 –

+0

@WajidAliKhan - 你使用哪個**命令名? –

+0

iCommandName =「ApplicantShortList」,我用它不是Rowcommand –

相關問題