I am getting an error:
There is no row at position 4
This means that the datatable doesn't have the row number I specified.
Below is an example:
protected void btnNext_Click1(object sender, EventArgs e)
{
if (Session["ClickCount"] == null)
Session["ClickCount"] = 0;
int ClickCount = Convert.ToInt32(Session["ClickCount"]) + 1;
Session["ClickCount"] = ClickCount;
DAL.TicketsDataSetTableAdapters.TicketDetailsTableAdapter eobj = new DAL.TicketsDataSetTableAdapters.TicketDetailsTableAdapter();
DataTable dt = new DataTable();
dt = eobj.GetTicketUpdates(txtSupportRef.Text);
if (ClickCount > dt.Rows.Count)
{
// HOW DO WE HANDLE THE ERROR?
}
txtNextStep.Text = dt.Rows[ClickCount - 1]["NextStep"].ToString();
}
I have 3 rows in my datatable and if click the button again it will give me the error message above.
What is the best way to handle this error message?
Should I exit out of the the if statement and then present the user with a message?
Aucun commentaire:
Enregistrer un commentaire