SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Bakersfield, CA
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating dynamic URL's

    Good Morning,

    I'm really new at .net, and programming in general. So I need some guidance to anyone that is willing to help me out

    I'm trying to create "dynamic URL's", at least thats what I call them heh.

    Below is my aspx code

    <formid="Form1"Runat="Server">

    <P></P>

    <asp:HyperLinkColumnText='Links'
    DataNavigateUrlField="NavigationID"
    DataNavigateUrlFormatString="search.aspx?catid={0}"
    HeaderText="Tier Links"/>
    <br/>
    <br/>






    </form>
    VB Code:


    Imports System
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Configuration
    Imports System.Web.UI.WebControls.HyperLinkColumn
    PartialClass guides
    Inherits System.Web.UI.Page
    Dim objConn As SqlConnection
    Dim objCmd As SqlCommand
    Dim strSql AsString
    'Dim CatTitle As String = Request.QueryString("CatTitle")
    Dim CatTitle AsString = Request.QueryString("CatTitleid")
    Sub Page_Load(ByVal sender AsObject, ByVal e As EventArgs)
    objConn = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnString").ConnectionString)
    objConn.Open()
    'strSql = "SELECT [CatTitle] FROM [Category] VALUES (@CatTitle)"
    strSql = "SELECT [CatTitle] FROM [Category] where CatTitle = " & CatTitle Or strSql = "SELECT [CatTitle] FROM [Category] where CatTitle = (@CatTitleid)"
    objCmd = New SqlCommand(strSql, objConn)
    objCmd.ExecuteNonQuery()
    objConn.Close()
    EndSub
    EndClass



    Any ideas would be greatly appreciated.

  2. #2
    SitePoint Member xela220's Avatar
    Join Date
    Oct 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First you need to correct this:
    Dim CatTitle AsString = Request.QueryString("CatTitleid")

    to this:
    Dim CatTitle As String = Request.QueryString("CatTitleid")


    Second the sql statement wont work the way you have it
    Correct this:
    strSql = "SELECT [CatTitle] FROM [Category] where CatTitle = " & CatTitle Or strSql = "SELECT [CatTitle] FROM [Category] where CatTitle = (@CatTitleid)"

    To this:
    strSql = "SELECT [CatTitle] FROM [Category] where CatTitle = " & CatTitle Or strSql = "SELECT [CatTitle] FROM [Category] where CatTitle =" + CatTitle


    As to the hyperlink. I am confused. Are yo trying to populate values in a datagrid or is it a stand alone hyperlink in your page.


    If it is a Hyperlink, you can set the vale in the codebehind like this

    _HyperLink1.NavigateUrl = "search.aspx?catid=" + _ValueFromDatabase

    The fron would be like this:
    <asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>



    Hope this helps.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Bakersfield, CA
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As to the hyperlink. I am confused. Are yo trying to populate values in a datagrid or is it a stand alone hyperlink in your page.
    I'm trying to populate all the categories from the table and list them out.

    Just like this

    http://kb.wisc.edu/helpdesk/topics.php

    And then when you click it pulls the articles in that category ...

    Thank you SO much.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •