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>
<asp:Label ID="Label4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"adate") %>'></asp:Label>
<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>
ASKER
ASKER
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
TRUSTED BY
ASKER
I would I apply that