c# - Datagridview not selecting last row -
i selecting records datagridview... have got 5 rows in datgridview , trying select each , of them click of buton(nextrecordbutton). working running problem 4 rows selected , last row isn't selected. there doing wrong in code below:
private void btnnext_click(object sender, eventargs e) { if (empcounter < dataset.tables[0].rows.count - 1) { txtdisplay.text = dataset.tables[0].rows[empcounter]["emp_name"].tostring(); } }
this working running problem 4 rows selected , last row isn't selected.
because check checking till second last row
empcounter < dataset.tables[0].rows.count - 1 it should be:
empcounter < dataset.tables[0].rows.count so code should be:
private void btnnext_click(object sender, eventargs e) { if (empcounter < dataset.tables[0].rows.count) { txtdisplay.text = dataset.tables[0].rows[empcounter]["emp_name"].tostring(); } }
Comments
Post a Comment