Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

my code body does not execute with first click in click event?

$
0
0

i have this code in my project that i do it with a help in this web site, my code check the datagridviewcheckboxcolumn checked state after that it checks another cell of datagridview with these to checks it execute a method, all my code is inside a button click. this is my code

privatevoid update_bt_Click(object sender,EventArgs e){var current_year =DateTime.Today.Year;var last_year =DateTime.Today.Year-1;for(int i =0; i < dgv_student_update.Rows.Count; i++){Func<DataGridViewRow,int,int> cellValue =(row, j)=>{int.TryParse(row.Cells["stg_id"].Value.ToString(),out j);return j;};DataGridViewCheckBoxCell chkchecking = dgv_student_update.Rows[i].Cells["result"]asDataGridViewCheckBoxCell;if(Convert.ToBoolean(chkchecking.Value)==true){//check if cell[3] in each row equal to stage id (1=first stage).if(cellValue(dgv_student_update.Rows[i],3)==1){ sc.year_student_update(Convert.ToInt32(dgv_student_update.Rows[i].Cells[1].Value), dgv_student_update.Rows[i].Cells[2].Value.ToString(),2);}}}}

when i click button it does not execute the "year_student_update()" method but at the second click it do the job. anyone can help me please?



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>