2017-06-01 8 views
0

でGridViewの列の値を取得するこれは私が試してみましたが、私はjob_NamenullあるJOB_NAMEは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; 

にnullを取得mのものです。

答えて

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

私はエラーを取得M '' は、入力文字列が正しい形式ではありませんでした。 '' VAR指数= Convert.ToInt32(e.CommandArgument)に。 –

+0

@WajidAliKhan - どちらのコマンド名**を使用していますか? –

+0

iCommandName = "ApplicantShortList"と私はそれをRowcommandではない –

関連する問題