Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2005, 01:09 PM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a hyperlink with multiple values

Hello,

I am trying to make a datagrid list the Headlines of Jokes from my database. When the user clicks on a link they would get transported to another PAge(detailedpage.aspx) to see the joke Headline and Joke Text. Here is how I've done it so far. However, something is missing as it does not work. I am not familiar with Codebehind. I think that may be it. Could someone please advise as to what I need to do here.

thanks,

Ray

jokepage.aspx

<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    Sub Page_load(Sender as object, e as EventArgs)
        Dim objConnection As OleDbConnection
        DIm objCommand As OleDbDataAdapter
        Dim strConnect As String
        Dim strCommand AS string
        Dim Dataset1 As New DataSet

        strConnect="Provider=Microsoft.Jet.OLEDB.4.0;"
        strConnect+="Data Source=C:\BegASPNet11\jokesdata.mdb;"
        strConnect+="Persist Security Info=False"
        strCommand = "SELECT JokeHeadline, jokeText FROM jokes"

        objConnection = New OleDbConnection (strConnect)
        objCommand = New OleDbDataAdapter (strCommand, objConnection)
        objCommand.Fill(DataSet1, "jokes")

        DataGrid1.DataSource=DataSet1.Tables("jokes").Defa ultview
        DataGrid1.Databind()
    end sub

</script>

<html>
<head>
    <title>Datagrid Control Example</title>
</head>
<body>
    <asp:DataGrid id="DataGrid1" runat="server"
AutoGenerateColumns="False" width="650px"
bordercolor="#6699cc" borderwidth="1"
cellpadding="4" font-Name="Verdana"
font-size="10pt"
headerStyle-BackColor="#6699cc">
        <HeaderStyle backcolor="#6699CC"></HeaderStyle>
        <Columns>

<asp:TemplateColumn>
<Itemtemplate>
    <asp:Hyperlink runat=”server” Text =”Joke Headlines. Click to view Joke”
    navigateUrl=’<%# detailedpage.aspx?JokeHeadline=” & _
    Container.DataItem(“JokeHeadline”) & _
    â€œ&JokeText=” & Container.DataItem(“JokeText”) %>’ />

</itemtemplate>
</asp:TemplateColumn>

        </Columns>
    </asp:DataGrid>
    <br />
</body>
</html>



detailedpage.aspx

<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

lbl1.text=Request.QueryString[“cJokeHeadline”].ToString()
lbl2.text=Request.QueryString[“cJokeText”].ToString()

</script>

<asp:label name=”lbl1” runat=”server” />
<br/>
<asp:label name=”lbl2” runat=”server” />







Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a list but not displaying certain values josephine XSLT 2 October 4th, 2007 10:37 AM
DataGrid/Hyperlink w multiple parameters gobotsoup ASP.NET 2.0 Basics 11 February 21st, 2007 05:49 PM
Creating a Hyperlink in a datagrid aadz5 ASP.NET 1.0 and 1.1 Basics 0 October 25th, 2003 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.