lynn tan

lynn tan

  • NA
  • 12
  • 0

index was out of range.. please help me -_-;;

Jun 26 2006 4:25 AM
This is the error i got when i am trying to save my new addition of details into the database.. and i went a step through and found out that the error comes from the '(dgvCard.DataKeys[dgvCard.SelectedIndex].Value.ToString()) ' area and i noticed that dgvcard.selectedIndex = -1 and its edited index is also -1
the error message is per below:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
else if (state == "edit")
{
updatestate = "u";
}
Message = DuCard.CardUpdate(int.Parse(dgvCard.DataKeys[dgvCard.SelectedIndex].Value.ToString())-> error comes from here, txtCompany.Text.Trim(), txtAddress.Text.Trim(),
txtUrl.Text.Trim(), txtEmail.Text.Trim(), dlCategory.SelectedValue.ToString(), txtName.Text.Trim(), txtTel.Text.Trim(), txtFax.Text.Trim(),
txtMobile.Text.Trim(), txtPosition.Text, txtCollected.Text.Trim(), DateTime.Parse(txtStartDate.Text.Trim()), UserAccess.userid, updatestate,
txtRegion.Text.Trim(), txtRemark.Text.Trim(), txtBriefname.Text.Trim(),ddlTosaleman.SelectedValue.ToString());
return Message;
}
this is one of our ex programmer's coding and i am here to solved this error.. and i am still a newbie in programming.. please help me..

Answers (1)