hi there, i get a Argument Out of Range Exception in the line "dgvDAction.Rows[r].Cells[0].Value = dt.Rows[r]["TActionDes"].ToString();" when it runs for the second time.dt.Rows.Count = 2.
why is this happening???
String query = @"Select TActionDes,TAssignTo,TDueDate,TStatus,TDateComplete,TComment from TopicAction Where TopicNo=@topicno and Phase=@phase ";
SqlCommand command = new SqlCommand(query, DB.getConnection());
command.Parameters.Add("@topicno", SqlDbType.VarChar).Value = tno;
command.Parameters.Add("@phase", SqlDbType.Int).Value = phase;
// DataGridViewCheckBoxColumn checkbox = (DataGridViewCheckBoxColumn)dgvDAction.Rows[0].Cells[3].OwningColumn;
SqlDataAdapter da = new SqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
//dgvDAction.DataSource = dt;
for (int r = 0; r < dt.Rows.Count ; r++)
{
//dgvDAction.Rows.Add();
// dt.Rows[0]["TStatus"] = !((bool)dt.Rows[0]["TStatus"]);
//dgvDAction.CurrentRow.Cells["Column3"].Value = "Vale is true";
dgvDAction.Rows[r].Cells[0].Value = dt.Rows[r]["TActionDes"].ToString();
dgvDAction.Rows[r].Cells[1].Value = dt.Rows[r]["TAssignTo"].ToString();
dgvDAction.Rows[r].Cells[2].Value = dt.Rows[r]["TDueDate"].ToString();
dgvDAction.Rows[r].Cells[3].Value = dt.Rows[r]["TStatus"].ToString();
dgvDAction.Rows[r].Cells[4].Value = dt.Rows[r]["TDateComplete"].ToString();
dgvDAction.Rows[r].Cells[5].Value = dt.Rows[r]["TComment"].ToString();
}
db10.closeConnection();
thanxxx