Partial Class mygababit_member_addressbook Inherits System.Web.UI.Page #Region " Variables" Private mintUserID As Integer #End Region Protected Sub Page_PreRender(ByVal s As Object, ByVal e As EventArgs) Handles Me.PreRender 'if the user is an admin, allow adding/editing public cateogries If CBool(Session("IsAdmin")) Then grdCategories.Columns(grdCategories.Columns.Count - 1).Visible = True DirectCast(frmAddCategory.Row.FindControl("pnlIsPublic"), Panel).Visible = True End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load mintUserID = Session("UserID") If Not IsPostBack Then LoadGroupDDL() End If End Sub Private Sub LoadGroupDDL() Dim ddlCategories As DropDownList ddlCategories = DirectCast(frmAddContact.Row.FindControl("ddlCategories"), DropDownList) ddlCategories.Items.Clear() ddlCategories.Items.Add("") ddlCategories.DataBind() End Sub Protected Sub SQLCateogries_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SQLCateogries.Selecting If CBool(Session("IsAdmin")) Then e.Command.Parameters("@ShowPublic").Value = 1 Else e.Command.Parameters("@ShowPublic").Value = 0 End If End Sub Protected Sub SQLCateogries_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SQLCateogries.Inserted LoadGroupDDL() End Sub Protected Sub SQLContacts_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SQLContacts.Inserting e.Command.Parameters("@CategoryID").Value = DirectCast(frmAddContact.Row.FindControl("ddlCategories"), DropDownList).SelectedValue End Sub End Class