Ø
Øyvind Isaksen
I have a reperater that returns 5 last articles from a given category.
In the bottom of the list (in the FooterTemplate) I want to make a link to
a page that list all articles in this category. How can I get the Category
ID from the repeater???
----------------------------------------------
This is the ASPX.VB file (codebehind-code):
----------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim SQL As String = "select top 5 artID,catID,title,regdate from
tblArticle where active='1' and catID=@catID"
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand(SQL, conn)
Dim parameter1 As New SqlParameter("@catID", variables.newsID)
'variables.newsID is a class that returns the categoryID
cmd.Parameters.Add(parameter1)
cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.rptNewsList.DataSource = dr
Me.rptNewsList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
------------------------------
This is the ASPX-file:
------------------------------
<asp:Repeater id="rptNewsList" runat="server">
<HeaderTemplate>
News
</HeaderTemplate>
<ItemTemplate>
<a
href="detail.aspx?cat=<%#container.dataitem("catID")%>&artID=<%#container.dataitem("artID")%>"><%#container.dataitem("title")%></a>
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
<FooterTemplate>
[<a href="/ld/default.aspx?catID=HERE-I-NEED-THE-CATEGORY-ID">Show
all</a>]
</FooterTemplate>
</asp:Repeater>
In the bottom of the list (in the FooterTemplate) I want to make a link to
a page that list all articles in this category. How can I get the Category
ID from the repeater???
----------------------------------------------
This is the ASPX.VB file (codebehind-code):
----------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim SQL As String = "select top 5 artID,catID,title,regdate from
tblArticle where active='1' and catID=@catID"
Dim conn As New SqlConnection(variables.ConnString)
Dim cmd As New SqlCommand(SQL, conn)
Dim parameter1 As New SqlParameter("@catID", variables.newsID)
'variables.newsID is a class that returns the categoryID
cmd.Parameters.Add(parameter1)
cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.rptNewsList.DataSource = dr
Me.rptNewsList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
------------------------------
This is the ASPX-file:
------------------------------
<asp:Repeater id="rptNewsList" runat="server">
<HeaderTemplate>
News
</HeaderTemplate>
<ItemTemplate>
<a
href="detail.aspx?cat=<%#container.dataitem("catID")%>&artID=<%#container.dataitem("artID")%>"><%#container.dataitem("title")%></a>
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
<FooterTemplate>
[<a href="/ld/default.aspx?catID=HERE-I-NEED-THE-CATEGORY-ID">Show
all</a>]
</FooterTemplate>
</asp:Repeater>