Ragazzi ho un problema con un Container.
Ho una pagina aspx che deve visualizzare delle news che preleva da un db; nel codebehind mi faccio restituire un arraylist di notizie che viene settato come datasource di un repeater.
Il problema è che devo creare dinamicamente un collegamento ipertestuale x ogni notizia in maniera tale che apra in un'altra finestra la notizia cliccata.
Se scrivo
codice:
<%# (Container.DataItem).getId() %>
l'id lo ottengo .. ma se lo inserisco in un codice tipo
non scrive niente...
Come posso risolvere?
Questo è il codice della pagina aspx :
codice:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="index.aspx.vb" Inherits="NewsSanita.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Repeater id="rptNotizie" runat="server">
<HeaderTemplate>
<table border=0>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# (Container.DataItem).getId() %>
<%# (Container.DataItem).getTitolo() %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</HTML>
E questo è invece il codebehind :
codice:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Codice generato da Progettazione Web Form "
'Chiamata richiesta da Progettazione Web Form.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents rptNotizie As System.Web.UI.WebControls.Repeater
'NOTA: la seguente dichiarazione è richiesta da Progettazione Web Form.
'Non spostarla o rimuoverla.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: questa chiamata al metodo è richiesta da Progettazione Web Form.
'Non modificarla nell'editor del codice.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim Id_Server As String = ConfigurationSettings.AppSettings("Id_Server")
Dim Id_Db As String = ConfigurationSettings.AppSettings("Id_Db")
Dim Id_Utente As String = ConfigurationSettings.AppSettings("Id_Utente")
Dim Id_Psw As String = ConfigurationSettings.AppSettings("Id_Psw")
StrConnDb = "server=" & Id_Server & "; database=" & Id_Db & "; uid=" & Id_Utente & "; pwd=" & Id_Psw & ";"
End If
Dim listaNotizie As ArrayList = New Notizia().getNotizie
rptNotizie.DataSource = listaNotizie
rptNotizie.DataBind()
End Sub
End Class