How do I have datagrid hyperlinks?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan

    How do I have datagrid hyperlinks?


    In the sample code below, how do I make the various text items in a datagrid
    column have a clickable hyperlinks?

    e.g. Ford Mustang

    should be a link to www.mysite.com/mustang.htm


    </head>

    <%@ Page language="VB" Debug="true" %>
    <%@ Import Namespace="Syst em.Data" %>
    <%@ Import Namespace="Syst em.Data.OleDb" %>

    <script language="VB" runat="server">

    Sub Page_Load(Sende r as Object, E as EventArgs)

    Dim oConn As OleDbConnection
    Dim oComm As OleDbDataAdapte r
    Dim sConn As String
    Dim sComm As String
    Dim oDataSet As New DataSet

    'Build the connection string
    sConn = "Provider=Micro soft.Jet.OLEDB. 4.0;"
    sConn += "Data Source=D:\inetp ub\www\mysite\m yaccessdb.mdb;"
    sConn += "Persist Security Info=False"

    'Build the SQL string
    sComm = "SELECT qryDataGrid01.* "
    sComm += "FROM qryDataGrid01;"

    'Create the connection and command objects
    oConn = New OleDbConnection (sConn)
    oComm = New OleDbDataAdapte r(sComm, oConn)

    'Fill the dataset with the results of the query
    oComm.Fill(oDat aSet, "qryDataGrid01" )

    'Set the grid source to the dataset and bind the data
    oGrid.DataSourc e=oDataSet.Tabl es("qryDataGrid 01").DefaultVie w
    oGrid.DataBind( )

    End Sub
    </script>


    <asp:DataGrid runat="server" id="oGrid" BackColor="#eee eee"
    HorizontalAlign ="Left">
    <HeaderStyle Font-Bold="True"/>
    <AlternatingIte mStyle BackColor="Whit e" />
    </asp:datagrid>



  • Masudur

    #2
    Re: How do I have datagrid hyperlinks?

    On Feb 18, 4:26 pm, "Jonathan" <n...@none.comw rote:
    In the sample code below, how do I make the various text items in a datagrid
    column have a clickable hyperlinks?
    >
    e.g. Ford Mustang
    >
    should be a link towww.mysite.co m/mustang.htm
    >
    </head>
    >
    <%@ Page language="VB" Debug="true" %>
    <%@ Import Namespace="Syst em.Data" %>
    <%@ Import Namespace="Syst em.Data.OleDb" %>
    >
    <script language="VB" runat="server">
    >
    Sub Page_Load(Sende r as Object, E as EventArgs)
    >
    Dim oConn As OleDbConnection
    Dim oComm As OleDbDataAdapte r
    Dim sConn As String
    Dim sComm As String
    Dim oDataSet As New DataSet
    >
    'Build the connection string
    sConn = "Provider=Micro soft.Jet.OLEDB. 4.0;"
    sConn += "Data Source=D:\inetp ub\www\mysite\m yaccessdb.mdb;"
    sConn += "Persist Security Info=False"
    >
    'Build the SQL string
    sComm = "SELECT qryDataGrid01.* "
    sComm += "FROM qryDataGrid01;"
    >
    'Create the connection and command objects
    oConn = New OleDbConnection (sConn)
    oComm = New OleDbDataAdapte r(sComm, oConn)
    >
    'Fill the dataset with the results of the query
    oComm.Fill(oDat aSet, "qryDataGrid01" )
    >
    'Set the grid source to the dataset and bind the data
    oGrid.DataSourc e=oDataSet.Tabl es("qryDataGrid 01").DefaultVie w
    oGrid.DataBind( )
    >
    End Sub
    </script>
    >
    <asp:DataGrid runat="server" id="oGrid" BackColor="#eee eee"
    HorizontalAlign ="Left">
    <HeaderStyle Font-Bold="True"/>
    <AlternatingIte mStyle BackColor="Whit e" />
    </asp:datagrid>
    Hi...

    Add columns for your grid...
    Edit the item template and make the items whatever you like

    Thanks
    Md. Masudur Rahman




    Comment

    • gnewsgroup

      #3
      Re: How do I have datagrid hyperlinks?

      On Feb 18, 5:26 am, "Jonathan" <n...@none.comw rote:
      In the sample code below, how do I make the various text items in a datagrid
      column have a clickable hyperlinks?
      >
      e.g. Ford Mustang
      >
      should be a link towww.mysite.co m/mustang.htm
      >
      </head>
      >
      <%@ Page language="VB" Debug="true" %>
      <%@ Import Namespace="Syst em.Data" %>
      <%@ Import Namespace="Syst em.Data.OleDb" %>
      >
      <script language="VB" runat="server">
      >
      Sub Page_Load(Sende r as Object, E as EventArgs)
      >
      Dim oConn As OleDbConnection
      Dim oComm As OleDbDataAdapte r
      Dim sConn As String
      Dim sComm As String
      Dim oDataSet As New DataSet
      >
      'Build the connection string
      sConn = "Provider=Micro soft.Jet.OLEDB. 4.0;"
      sConn += "Data Source=D:\inetp ub\www\mysite\m yaccessdb.mdb;"
      sConn += "Persist Security Info=False"
      >
      'Build the SQL string
      sComm = "SELECT qryDataGrid01.* "
      sComm += "FROM qryDataGrid01;"
      >
      'Create the connection and command objects
      oConn = New OleDbConnection (sConn)
      oComm = New OleDbDataAdapte r(sComm, oConn)
      >
      'Fill the dataset with the results of the query
      oComm.Fill(oDat aSet, "qryDataGrid01" )
      >
      'Set the grid source to the dataset and bind the data
      oGrid.DataSourc e=oDataSet.Tabl es("qryDataGrid 01").DefaultVie w
      oGrid.DataBind( )
      >
      End Sub
      </script>
      >
      <asp:DataGrid runat="server" id="oGrid" BackColor="#eee eee"
      HorizontalAlign ="Left">
      <HeaderStyle Font-Bold="True"/>
      <AlternatingIte mStyle BackColor="Whit e" />
      </asp:datagrid>
      Just a reminder: there is a HyperLink field if you use GridView
      (ASP.NET 2.0). But if you cannot use ASP.NET 2.0, that's another
      story.

      Comment

      Working...