Hyperlink to other page with specific article

3 posts, 1 answers
  1. David De Backer
    David De Backer avatar
    8 posts
    Member since:
    Mar 2010

    Posted 11 Apr 2010 Link to this post

    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. Answer
    Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 14 Apr 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David De Backer
    David De Backer avatar
    8 posts
    Member since:
    Mar 2010

    Posted 14 Apr 2010 Link to this post

    Hello Rosen,
    Thanks for your great support!
    David
Back to Top