Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem
Detailsview hyperlink problem Detailsview hyperlink problem
Detailsview hyperlink problem
Go Back  Xtreme Visual Basic Talk > > > Detailsview hyperlink problem


Reply
 
Thread Tools Display Modes
  #1  
Old 07-10-2007, 11:26 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default Detailsview hyperlink problem


ok...i have a detailsview control which can display the details of a movie according to the MovieID which it retrieves from another page. A first page displays search results and the title appears as a link. When clicked it sends the MovieID of that movie to the details page which has the detailsview control. The detailsview then gets the MovieID and all the details of that movie displayed in it. Up until here everything works well.

now i need to get the actors displayed in the detailsview as a hyperlink and each actor separated by commas. Like in amazon.com when u search for a movie, the results appear in a list, and when u click a title, another page loads and shows the details of that movie. then on that page, the name of the actors and displayed as links and separated by commas.

e.g Starring: Actor Name , Another Actor

like that...so i need the actors field in my detailsview to display the actors like that....so how do i do it?
Reply With Quote
  #2  
Old 07-11-2007, 10:43 AM
MKoslof's Avatar
MKoslofDetailsview hyperlink problem MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

I believe using a DataGridView and a template column might be the most straightforward and flexible way.

Code:
<Columns>
   <asp:BoundField DataField="ThisID" />
   <asp:HyperLinkField DataNavigateUrlFields="ThisID"  DataNavigateUrlFormatString="ThisForm.aspx?id={0}"
  DataTextField="ThisName" NavigateUrl="ThisForm.aspx" />
 </Columns>
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #3  
Old 07-11-2007, 08:43 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

yay!...that works..
Thanks MKoslof.

Last edited by shah_rizal; 07-11-2007 at 08:52 PM.
Reply With Quote
  #4  
Old 07-11-2007, 08:50 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

hold up.....i tried ur method MKoslof, but not on this problem....tried it on another problem which i did not post on this forum...that works...strange...haha...anyway still havent solved this problem.....anyone??

Last edited by shah_rizal; 07-12-2007 at 03:38 AM.
Reply With Quote
  #5  
Old 07-12-2007, 08:32 AM
MKoslof's Avatar
MKoslofDetailsview hyperlink problem MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

What isn't solved if you can build those grid columns, which it appears you can, you get the hyperlink functionality that you requested in a grid like, display fashion. Please explain what's not working.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #6  
Old 07-12-2007, 08:24 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

tat's ok...i managed to get the hyperlinks separated by commas...used literals as suggested by someone at asp.net forums....
Code:
   Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
        Dim l As Literal = DirectCast(Me.DetailsView1.FindControl("L1"), Literal)
        Dim drv As DataRowView = DirectCast(Me.DetailsView1.DataItem, DataRowView)
        Dim s As String = drv("Actor").ToString()
        Dim s1 As String = s.Substring(0, 3)
        Dim s2 As String = s.Substring(3, 5)
        'l.Text += "Hello:"
        Dim result As String() = s.Split(","c)
        Dim i As Integer = 0
        While i < result.Length - 1
            l.Text += "<a href='" + result(i) + "'>" + result(i) + "</a>"
            l.Text += "&nbsp,&nbsp"
            i += 1
        End While
        l.Text += "<a href='" + result(i) + "'>" + result(i) + "</a>"
    End Sub
another problem...how do i get the actor names to hyperlink to another form showing the movies he's starred in?...i've done that for the director but that's easier cos there's only one director and i used a hyperlink field for the director in the detailsview....
Reply With Quote
  #7  
Old 07-13-2007, 10:07 AM
MKoslof's Avatar
MKoslofDetailsview hyperlink problem MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

Like I displayed in my first post. A Hyperlink column in a DataGridView has a URLFormat property

Code:
DataNavigateUrlFormatString="ThisForm.aspx?id={0}"
"ThisForm" is the target form to open. The {0} reperensents the parameter value which will be send as a query string. Which is why we also name the DataTextField:

Code:
DataTextField="ThisName"
So if the data column "ThisName" contains "MKoslof" the hyperlink field would open up "ThisForm" and send in the ID query string param with the proper value

ThisForm.aspx?id='MKoslof'

Then in the form load event of "ThisForm" check if the Id query string value is not null and if so, grab the value. From here you can query the database or do what you need with the value of "MKoslof"
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #8  
Old 07-15-2007, 08:12 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

thanks...i get what ur saying...i already did that for the director...but since there's only director, i used on hyperlinkfield in the detailsview...it has an URLformat property too..
HTML Code:
<asp:HyperLinkField DataTextField="Director" HeaderText="Director" NavigateUrl="DirectorMovies.aspx" DataNavigateUrlFields="Director" DataNavigateUrlFormatString="DirectorMovies.aspx?Director={0}" SortExpression="Director" >
                     <HeaderStyle Font-Bold="True" HorizontalAlign="Right" />
                 </asp:HyperLinkField>
and in the directormovies.aspx i did this to get the director's movies...
Code:
 If (Request.QueryString("Director") IsNot Nothing) Then
            Try
                Dim ID As String
                If (Request.QueryString("Director") IsNot Nothing) Then
                    ID = Request.QueryString("Director")
                    strSQL = "SELECT * FROM Dvd_details WHERE Director = '" + ID + "'"
                    Session("ID3") = ID
                    Dim dtRecord As New OleDb.OleDbDataAdapter(strSQL, conn)
                    dtRecord.SelectCommand.CommandType = CommandType.Text
                    conn.Open()
                    Dim dsView As New DataSet
                    dtRecord.Fill(dsView)
                    Me.DataList1.Visible = True
                    Me.DataList1.DataSource = dsView
                    Me.DataList1.DataBind()
                    conn.Close()
                End If
            Catch ex As Exception
            End Try
        End If
so i think i understand the whole concept of getting the ID and sending it to the other page etc....

now for the actors i used a template field containing a literal and the actor hyperlinks are separated like: Actor Name, Another Actor
not a hyperlinkfield like i did for the director...
so i dont think i can do exactly what i did for the director for the actor...
Reply With Quote
  #9  
Old 07-16-2007, 09:26 AM
MKoslof's Avatar
MKoslofDetailsview hyperlink problem MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

Sorry, I don't follow, why can't you use the same approach. What are you trying to do with actors? Meaning, yes, I understand that relationally an actor can be part of multiple movies and other related entities, while a director is associated with a single movie. How are you presenting the data? And on an "actor" hyperlink or literal click, what do you want to do? Just because you have a one to many relationship doesn't mean you can't send a single value via the query string - - but behind the scenes in the form load event you have the proper stored procedure or query to return all the data neccessary given you have all the keys you need.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #10  
Old 07-16-2007, 09:29 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

ok...if i use a hyperlinkfield for the actor like i did for the director, the actor names will look like this : Actor Name, Another Actor, And Another... so how can i send the actor name to the actorMovies.aspx page when the its displayed like that?...so i used literals...
and for the literal's text, i did this:
Code:
 l.Text += "<a href='ActorMovies.aspx?Actor=" + result(i) + "'>" + result(i) + "</a>"
to send the 'Actor' to ActorMovies.aspx and...
Code:
If (Request.QueryString("Actor") IsNot Nothing) Then
            Try
                Dim ID As String
                If (Request.QueryString("Actor") IsNot Nothing) Then
                    ID = Request.QueryString("Actor")
                    strSQL = "SELECT * FROM Dvd_details WHERE Actor = '" + ID + "'"

                    Session("ID4") = ID
                    Dim dtRecord As New OleDb.OleDbDataAdapter(strSQL, conn)
                    dtRecord.SelectCommand.CommandType = CommandType.Text
                    conn.Open()
                    Dim dsView As New DataSet
                    dtRecord.Fill(dsView)
                    Me.DataList1.Visible = True
                    Me.DataList1.DataSource = dsView
                    Me.DataList1.DataBind()
                    conn.Close()
                End If
            Catch ex As Exception
            End Try
        End If
to get that 'Actor'...when the ActorMovies.aspx page loads, the URL looks like
http://localhost:1169/webdvd/ActorMo...jessica%20Alba
Reply With Quote
  #11  
Old 07-16-2007, 09:44 PM
Eduardo Lorenzo's Avatar
Eduardo Lorenzo Eduardo Lorenzo is offline
Senior Contributor
 
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
Default

then the previous page passed the actor name instead of the ID.
__________________
Pinoy ako.. ipinagmamalaki ko.
Reply With Quote
  #12  
Old 07-16-2007, 10:16 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

?...i thought i already assigned the ID to the Actor..

Code:
ID = Request.QueryString("Actor")
Reply With Quote
  #13  
Old 07-16-2007, 10:24 PM
shah_rizal's Avatar
shah_rizal shah_rizal is offline
Newcomer
 
Join Date: Jun 2007
Location: Singapore
Posts: 20
Default

thanks guys...finally got it...there was something wrong with my SQL statement...
strSQL = "SELECT * FROM Dvd_details WHERE Actor LIKE '%" + ID + "%'"
fixed it...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem Detailsview hyperlink problem
Detailsview hyperlink problem
Detailsview hyperlink problem
 
Detailsview hyperlink problem
Detailsview hyperlink problem
 
-->