per favore aiutatemi a risolvere questo ... sto ricevendo errore come "non c'è riga nella posizione 0", "l'indice fuori dall'eccezione non è stato gestito da codice utente"Errore "non c'è riga nella posizione 0"
Di seguito è riportato il mio codice
protected void Page_Load(object sender, EventArgs e)
{
MTMSService obj = new MTMSService();
DBAccess db = new DBAccess();
{
MTMSDTO objc = new MTMSDTO();
{
objc.TaskID = Convert.ToInt32(Session["TaskID"]);
DataSet rep = obj.GetReports(objc);
DataView Rprts = new DataView();
Rprts.Table = rep.Tables[0];
LblTaskID.Text = rep.Tables[0].Rows[0]["TaskID"].ToString();
LblTaskName.Text = rep.Tables[1].Rows[0]["TaskName"].ToString();
LblDueDate.Text = rep.Tables[2].Rows[0]["DueDate"].ToString();
LblDescription.Text = rep.Tables[3].Rows[0]["Description"].ToString();
LblAssignBy.Text = rep.Tables[4].Rows[0]["AssignBy"].ToString();
LblStatus.Text = rep.Tables[5].Rows[0]["Status"].ToString();
LblPercentageComplete.Text =
rep.Tables[6].Rows[0]["PercentageComplete"].ToString();
LblTaskName.Visible = true;
LblAssignBy.Visible = true;
LblDescription.Visible = true;
LblDueDate.Visible = true;
LblStatus.Visible = true;
LblPercentageComplete.Visible = true;
LblAssignTo.Visible = false;
}
}
}
Bene, il messaggio è abbastanza chiaro, non è vero? Che cosa non capisci? Se 'rep.Tables [0]' non contiene alcuna riga, l'accesso a 'Rows [0]' genera un'eccezione. –
Controlla se ci sono delle righe nella tabella prima di provare ad usarla! –
** Debug ** e ** Watch ** –