Avatar of thomasm1948
thomasm1948Flag for United States of America

asked on 

Hyperlink in a datagrid

I have a quick question.  I know how to add a Hyperlink to a datagrid/dataview, but I would like the chile window to open with no scrollbars or toolbars.  I also need it to pass paremeters to the child window so that I can do a query on the database

I tried the hyperlink.attribute add, but it seems not work roght

The following is my code

thank you for all of your help
code behind:
 
Imports System
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
 
Partial Class Annoucements
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim SqlCon1 As New System.Data.SqlClient.SqlConnection
            Dim sConnSTr1 As String
            sConnSTr1 = "server=tomkat\SQLEXPRESS;uid=tech;pwd=Newpass01;database=test_techSupport"
            SqlCon1.ConnectionString = sConnSTr1
            SqlCon1.Open()
            Dim sqlCommand0 As New System.Data.SqlClient.SqlCommand
            sqlCommand0.CommandType = Data.CommandType.StoredProcedure
            sqlCommand0.CommandText = "dbo.annoucements"
            sqlCommand0.Connection = SqlCon1
            Dim adapter As New SqlDataAdapter(sqlCommand0)
            Dim ds As New DataSet()
            adapter.Fill(ds)
            ds.Relations.Add("InnerVal", ds.Tables(0).Columns("Title"), ds.Tables(1).Columns("Title"))
            grdAnnoucements.DataSource = ds.Tables(0)
            grdAnnoucements.DataBind()
            SqlCon1.Close()
        End If
 
    End Sub
 
    Protected Sub grdAnnoucements_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdAnnoucements.RowDataBound
        Dim loginUser As String
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim lnkMore As HyperLink = DirectCast(e.Row.FindControl("link"), HyperLink)
            lnkMore.Visible = True
            Dim lbl As Label = DirectCast(e.Row.FindControl("Label3"), Label)
            'lnkMore.NavigateUrl = "~/AnncEdit.aspx?pram1=" + lbl.Text
 
            lnkMore.Attributes.Add _
            ("onclick", "window.open('AnncEdit.aspx?pram1=',null,'left=400, top=100, height=250, width= 250, status=n o, resizable= no, scrollbars= no, toolbar= no,location= no, menubar= no'); ")
 
 
            If Session("User") = "" Then
            Else
                loginUser = "twhite" ' just for testing...I will pass variable for this
                If loginUser = Session("User") Then
                    lnkMore.Visible = True
                End If
            End If
        End If
    End Sub
End Class
 
HTML
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Annoucements.aspx.vb" Inherits="Annoucements" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    
    <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" 
        Font-Size="Small" Text="Annoucements"></asp:Label>
      
    <asp:GridView ID="grdAnnoucements" runat="server" CellSpacing="10" 
        GridLines="None" AutoGenerateColumns="False" Width="456px" OnRowDataBound="grdAnnoucements_RowDataBound">
        <Columns>
                <asp:TemplateField>
                <ItemTemplate>
                    <div style="color:Blue;font-weight:bold">
                        <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Title") %>'></asp:Label>
                       &nbsp;<asp:Label ID="Label4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"adate") %>'></asp:Label>
                       &nbsp;<asp:Label ID="Label3" runat="server" 
                            Text='<%# DataBinder.Eval(Container.DataItem,"id") %>' Visible="False"></asp:Label>
                    </div>
                    <asp:Repeater ID="Repeater1" runat="server" DataSource='<%#DataBinder.Eval(Container, "DataItem.InnerVal") %>'>
                    <ItemTemplate>
                    <div style="padding-left:20px; padding-top:5px">
                        <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"description").toString.Replace(vbCrLf, "")%>'></asp:Label>
                        
                    </div>
                    </ItemTemplate>
                    </asp:Repeater>
                   <div style="text-align:right">
                        <asp:HyperLink ID="link" runat="server" Target="_blank">Edit</asp:HyperLink>
                    </div>
                </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        
    </asp:GridView>
    
    </form>
</body>
</html>

Open in new window

ASP.NETVisual Basic.NETJavaScript

Avatar of undefined
Last Comment
thomasm1948
SOLUTION
Avatar of Odessa_Tech
Odessa_Tech

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of thomasm1948
thomasm1948
Flag of United States of America image

ASKER

The only thing is that I need the window to have no toolbars, fixed hieght and width

I would I apply that
Avatar of thomasm1948
thomasm1948
Flag of United States of America image

ASKER

Actually would that work the same with lnkMore.NavigateUrl = "~/AnncEdit.aspx?pram1=" + lbl.Text
I need to pass the lbl.text value to the next page
Avatar of thomasm1948
thomasm1948
Flag of United States of America image

ASKER

I just tested it and it does not work.  I need to pass the lbl.text value
ASKER CERTIFIED SOLUTION
Avatar of thomasm1948
thomasm1948
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo