Robb Hill
asked on
vb.net : There is no row at position 1.
The following line of code in the attached function crashes with the error "There is no row at position 1"
TextBox_Sent.Text= dt.Rows[1]["Sent"].ToStrin g();
I do not understand this since the value of dt.rows[0] has a value and the datatable gets populated with 1 row....
Any ideas..why this crashes?
Thanks
TextBox_Sent.Text= dt.Rows[1]["Sent"].ToStrin
I do not understand this since the value of dt.rows[0] has a value and the datatable gets populated with 1 row....
Any ideas..why this crashes?
Thanks
private void SetAgreement()
{
DataTable dt = GetProviderAssignmentAggreementData(AssignmentId);
if (dt.Rows.Count == 0)
{
hdn_AgreementFiledId.Value = TextBox_Sent.Text = TextBox_Received.Text = string.Empty;
}
else
{
hdn_AgreementFiledId.Value = dt.Rows[0]["AgreementFiledID"].ToString();
TextBox_Sent.Text= dt.Rows[1]["Sent"].ToString();
TextBox_Received.Text = dt.Rows[2]["Received"].ToString();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The datatable index starts at zero. So the first row goes into Rows[0]. You said you are only getting one row so there is no row to put into Row[1], which would be the second row.
ASKER