Torna al Thread

... try { conn.Open(); string selectcom = "SELECT AutoreID, Testo, DataOra, Oggetto, CommentoID FROM Home.Commenti WHERE RispostaID = 0 AND NewsID = @newsid ORDER BY DataOra DESC"; string selectrisp = "SELECT AutoreID, Testo, DataOra, Oggetto, RispostaID, CommentoID FROM Home.Commenti WHERE RispostaID <> 0 AND NewsID = @newsid"; SqlCommand cmdcomm = new SqlCommand(selectcom, conn); SqlCommand cmdrisp = new SqlCommand(selectrisp, conn); cmdcomm.Parameters.AddWithValue("@newsid", newsid); cmdrisp.Parameters.AddWithValue("@newsid", newsid); try { SqlDataReader readercomm = cmdcomm.ExecuteReader(); if (readercomm.HasRows) { while (readercomm.Read()) { App_Controls.commento commento = (App_Controls.commento)LoadControl("~/App_Controls/commento.ascx"); commento.UtenteID = readercomm.GetInt32(0); // ◄ ECCEZIONE SI VERIFICA LI' ◄ commento.Commento = readercomm.GetString(1); commento.DataOra = readercomm.GetDateTime(2); commento.Oggetto = readercomm.GetString(3); commento.ID = readercomm.GetInt32(4).ToString(); Panel panelCommenti = (Panel)RadPanelBar1.FindItemByValue("Commenti").FindControl("panelComm"); panelCommenti.Controls.Add(commento); } readercomm.Dispose(); SqlDataReader readerrisp = cmdrisp.ExecuteReader(); while (readerrisp.Read()) { Panel panelCommenti = (Panel)RadPanelBar1.FindItemByValue("Commenti").FindControl("panelComm"); App_Controls.commento risposta = (App_Controls.commento)LoadControl("~/App_Controls/commento.ascx"); risposta.IsRisposta = true; risposta.UtenteID = readerrisp.GetInt32(0); risposta.Commento = readerrisp.GetString(1); risposta.DataOra = readerrisp.GetDateTime(2); risposta.Oggetto = readerrisp.GetString(3); int commentoid = readerrisp.GetInt32(4); risposta.ID = readerrisp.GetInt32(5).ToString(); App_Controls.commento commento = (App_Controls.commento)panelCommenti.FindControl(commentoid.ToString()); commento.ActivateRisposte = true; commento.AddRisposta(risposta); } readerrisp.Dispose(); } else { Panel panelCommenti = (Panel)RadPanelBar1.FindItemByValue("Commenti").FindControl("panelComm"); Label labelNoComm = new Label(); labelNoComm.ID = "labelNoComm"; labelNoComm.Text = "Non è stato scritto ancora nessun commento per questa notizia. Scrivi il primo!"; labelNoComm.Font.Italic = true; panelCommenti.Controls.Add(labelNoComm); } } catch { } ...
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5