This is a migrated thread and some comments may be shown as answers.

Hyperlink to other page with specific article

2 Answers 112 Views
ListView
This is a migrated thread and some comments may be shown as answers.
David De Backer
Top achievements
Rank 1
David De Backer asked on 11 Apr 2010, 06:43 PM
Hello,
I have a database with the columns NewsID, date, category, title and content. I want to show the date, category and title in a Telerik Listview. When you click on the title (which is a hyperlink in the listview), I want to load a subpage with the full article (title+content). In which subpage it is loaded, depends on the category of the article. When the category is for example 'general', it is loaded in the default-page. When the category is 'dogs', it is loaded in subpages/dogs.aspx. When the category is 'fishes', it is loaded in subpages/fishes.aspx.

When I use a standard datalist, I do it in the following way:
 
    Protected Sub DataList_ItemDataBound(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList.ItemDataBound  
        Select Case e.Item.ItemType  
            Case ListItemType.Item, ListItemType.AlternatingItem  
                Dim myRow As DataRowView = CType(e.Item.DataItem, DataRowView)  
                Dim hype As HyperLink = e.Item.FindControl("DatalistHyperlink")  
                If myRow.Item("category") = "General" Then 
                    hype.NavigateUrl = "default.aspx?NewsID=" & myRow.Item("NewsID")  
                Else 
                    hype.NavigateUrl = "subpages/" & myRow.Item("category") & ".aspx?NewsID=" & myRow.Item("NewsID")  
                End If 
        End Select 
    End Sub 
 
What is the solution for this problem when I use a Telerik-listview instead of a standard datalist?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 14 Apr 2010, 11:56 AM
Hi David,

You can use the same general approach with our RadListView as with the MS DataList, with the appropriate code modifications of course. For example the code you have pasted will look similar to the following:

Protected Sub RadListView1_ItemDataBound(ByVal sender As Object, ByVal e As RadListViewItemEventArgs) Handles RadListView1.ItemDataBound
    If TypeOf e.Item Is RadListViewDataItem Then
        Dim dataItem = CType(e.Item, RadListViewDataItem)
        Dim myRow As DataRowView = CType(dataItem.DataItem, DataRowView)
        Dim hype As HyperLink = e.Item.FindControl("DatalistHyperlink")
        If myRow.Item("category") = "General" Then
            hype.NavigateUrl = "default.aspx?NewsID=" & myRow.Item("NewsID")
        Else
            hype.NavigateUrl = "subpages/" & myRow.Item("category") & ".aspx?NewsID=" & myRow.Item("NewsID")
        End If
    End If
End Sub

All the best,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David De Backer
Top achievements
Rank 1
answered on 14 Apr 2010, 07:49 PM
Hello Rosen,
Thanks for your great support!
David
Tags
ListView
Asked by
David De Backer
Top achievements
Rank 1
Answers by
Rosen
Telerik team
David De Backer
Top achievements
Rank 1
Share this question
or