Imports System.Data Imports System.Data.SqlClient Namespace UMSBA Public Class FacultyStaff Inherits UMSBA.UMSBATemplateOther Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid Private MyDataSet As DataSet = New DataSet() Private MyDataTable As DataTable = New DataTable() Private MyDataView As DataView = New DataView() Private sDSN As String = ConfigurationSettings.AppSettings("DatabaseConnectionString") Protected WithEvents ErrorMessageLabel As System.Web.UI.WebControls.Label Private MySQL As String = "Select * from professional WHERE list_dir='Y' order by lname, fname, mname" #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Try Dim MyConn As SqlConnection = New SqlConnection(sDSN) Dim MyCommand As SqlDataAdapter = New SqlDataAdapter(MySQL, MyConn) MyCommand.Fill(MyDataSet, "FacultyStaffData") MyDataTable = MyDataSet.Tables("FacultyStaffData") MyDataTable.Columns.Add("FullName", GetType(String), "salutation + ' ' + fname + ' ' + lname") MyDataTable.Columns.Add("FullURL", GetType(String), "") Dim row As DataRow For Each row In MyDataTable.Rows row("FullURL") = "FacultyStaffDetail.aspx?id=" & row("userid") Next MyDataView = MyDataTable.DefaultView DataGrid1.DataSource() = MyDataView DataGrid1.DataBind() ErrorMessageLabel.Visible = False Catch ex As Exception ErrorMessageLabel.Text = "The Faculty/Staff database is temporarily unavailable." ErrorMessageLabel.Visible = True End Try End If End Sub Protected Overrides Sub OnInit(ByVal oEvent As EventArgs) Title = "Faculty and Staff in Business Administration at The University of Mississippi" MyBase.OnInit(oEvent) End Sub Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand Try Dim MyConn As SqlConnection = New SqlConnection(sDSN) Dim MyCommand As SqlDataAdapter = New SqlDataAdapter(MySQL, MyConn) MyCommand.Fill(MyDataSet, "FacultyStaffData") MyDataTable = MyDataSet.Tables("FacultyStaffData") MyDataTable.Columns.Add("FullName", GetType(String), "salutation + ' ' + fname + ' ' + lname") MyDataTable.Columns.Add("FullURL", GetType(String), "") Dim row As DataRow For Each row In MyDataTable.Rows row("FullURL") = "FacultyStaffDetail.aspx?id=" & row("userid") Next MyDataView = MyDataTable.DefaultView MyDataView.Sort = e.SortExpression DataGrid1.DataSource() = MyDataView DataGrid1.DataBind() ErrorMessageLabel.Visible = False Catch ex As Exception ErrorMessageLabel.Text = "The Faculty/Staff database is temporarily unavailable." ErrorMessageLabel.Visible = True End Try End Sub End Class End Namespace