<
asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<
div id="divMsgs" runat="server" style="float: left;">
<asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"></asp:Label>
<asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"></asp:Label>
<
br />
</
div>
<
telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowSorting="True"
DataSourceID="SDS_UserInfo" GridLines="None" ShowFooter="True" Skin="Hay"
AutoGenerateColumns="False" ShowStatusBar="True" OnItemDeleted="RadGrid1_ItemDeleted"
OnItemInserted="RadGrid1_ItemInserted" OnItemUpdated="RadGrid1_ItemUpdated"
OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender"
DataMember="DefaultView" AllowPaging="True" ShowGroupPanel="True">
<
MasterTableView DataKeyNames="UserID" DataSourceID="SDS_UserInfo"
CommandItemDisplay
="TopAndBottom"
datamember="DefaultView" AllowPaging="False" EditFormSettings-EditColumn-Display="True"
AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" EditFormSettings-EditColumn-ButtonType="LinkButton"
runat="server" GroupsDefaultExpanded="False">
<
RowIndicatorColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete"
UniqueName="Delete">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="UserID" DataType="System.Int32"
HeaderText="UserID" ReadOnly="True" SortExpression="UserID" UniqueName="UserID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UserName" HeaderText="UserName"
SortExpression="UserName" UniqueName="UserName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Password" HeaderText="Password"
SortExpression="Password" UniqueName="Password">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name"
SortExpression="Name" UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AccessLevel" HeaderText="AccessLevel"
SortExpression="AccessLevel" UniqueName="AccessLevel">
</telerik:GridBoundColumn>
<%
--<telerik:GridTemplateColumn DataField="AccessLevel" DataType="System.Int32"
HeaderText="AccessLevel" SortExpression="AccessLevel" UniqueName="AccessLevel">
<EditItemTemplate>
<asp:CheckBoxList ID="CHKList_AccessLevel" runat="server"
DataSourceID="SDS_AccessLevel" DataTextField="AccessLevelName"
DataValueField="AccessLevelCode"
RepeatColumns="2" >
</asp:CheckBoxList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LBL_AccessLevel" runat="server"
Text='<%# Bind("AccessLevel") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>--
%>
<telerik:GridBoundColumn DataField="DSN" HeaderText="DSN" SortExpression="DSN"
UniqueName="DSN">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="COM" HeaderText="COM" SortExpression="COM"
UniqueName="COM">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Fax" HeaderText="Fax" SortExpression="Fax"
UniqueName="Fax">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Email" HeaderText="Email"
SortExpression="Email" UniqueName="Email">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="TechArea" HeaderText="TechArea"
SortExpression="TechArea" UniqueName="TechArea">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ServiceID" DataType="System.Int32"
HeaderText="ServiceID" SortExpression="ServiceID" UniqueName="ServiceID">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="nondisc" DataType="System.Int32"
HeaderText="nondisc" SortExpression="nondisc" UniqueName="nondisc">
</telerik:GridCheckBoxColumn >
<telerik:GridBoundColumn DataField="disclosure_signed"
DataType="System.DateTime" HeaderText="disclosure_signed"
SortExpression="disclosure_signed" UniqueName="disclosure_signed">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Service" HeaderText="Service"
SortExpression="Service" UniqueName="Service">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AccessLevelName"
HeaderText="AccessLevelName" SortExpression="AccessLevelName"
UniqueName="AccessLevelName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Organization" HeaderText="Organization"
SortExpression="Organization" UniqueName="Organization">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="OrganizationID" DataType="System.Int32"
HeaderText="OrganizationID" SortExpression="OrganizationID"
UniqueName="OrganizationID">
</telerik:GridBoundColumn>
</Columns>
<
EditFormSettings EditFormType="Template">
<
EditColumn UniqueName="EditCommandColumn1" ButtonType="ImageButton"></EditColumn>
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" width="500" border="0" rules="none"
style="border-collapse: collapse;background:white;">
<tr>
<td colspan="1" style="font-size: small" class="style3">
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Medium"
Text="User Info." Width="100px"></asp:Label>
</td>
<td class="style5" style="font-size: small">
</td>
<td class="style4" style="font-size: small">
</td>
</tr>
<tr>
<td class="style3">
<table ID="Table4" border="0" cellpadding="1" cellspacing="1">
<tr>
<td>
UserID:
</td>
<td>
<asp:Label ID="Label5" Text='<%# Bind("UserID") %>' runat="server" Width="200px"></asp:Label>
</td>
</tr>
<tr>
<td>
UserName:
</td>
<td>
<telerik:RadTextBox ID="RadTextBox16" Runat="server" InvalidStyleDuration="100"
Text='<%# Bind("UserName") %>' Width="200px" Skin="Hay">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<telerik:RadTextBox ID="RadTextBox17" Runat="server" InvalidStyleDuration="100"
Text='<%# Bind("Password") %>' Width="200px" Skin="Hay">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
Name:
</td>
<td>
<telerik:RadTextBox ID="RadTextBox18" Runat="server" InvalidStyleDuration="100"
Text='<%# Bind("Name") %>' Width="200px" Skin="Hay">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
DSN:
</td>
<td>
<telerik:RadMaskedTextBox ID="RadMaskedTextBox" Runat="server" InvalidStyleDuration="100"
Text='<%# Bind("DSN") %>' Width="200px" DisplayMask="###-####"
Mask="###-####" Skin="Hay">
</telerik:RadMaskedTextBox>
</td>
</tr>
<tr>
<td>
COM:
</td>
<td>
<telerik:RadMaskedTextBox ID="RadMaskedTextBox2"
Text='<%# Bind("COM") %>' Runat="server" Width="200px"
DisplayMask="(###) ###-####" Mask="(###) ###-####" Skin="Hay">
</telerik:RadMaskedTextBox>
</td>
</tr>
<tr>
<td>
Fax:
</td>
<td>
<telerik:RadMaskedTextBox ID="RadMaskedTextBox1"
Text='<%# Bind("Fax") %>' Runat="server" Width="200px"
DisplayMask="(###) ###-####" Mask="(###) ###-####" Skin="Hay">
</telerik:RadMaskedTextBox>
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<telerik:RadTextBox ID="RadTextBox23" Runat="server" InvalidStyleDuration="100"
Text='<%# Bind("Email") %>' Width="200px" Skin="Hay">
</telerik:RadTextBox>
</td>
</tr>
</table>
</td>
<td class="style5">
</td>
<td class="style4">
<table ID="Table5" border="0" cellpadding="1" cellspacing="1">
<tr>
<td class="style6">
Service:
</td>
<td>
<telerik:RadComboBox ID="DDL_Service" Runat="server" DataSourceID="SDS_Service"
DataTextField="Service" DataValueField="ServiceID" DropDownWidth="175px"
Height="100px" SelectedValue='<%# Bind("ServiceID") %>' Skin="Hay"
Width="150px">
<CollapseAnimation Duration="200" Type="OutQuint" />
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td class="style6">
Organization:
</td>
<td>
<telerik:RadComboBox ID="DDL_Organization" Runat="server" Height="100px"
Width="150px" DataSourceID="SDS_Organization" DataTextField="Organization"
DataValueField="OrganizationID" DropDownWidth="175px" Skin="Hay"
SelectedValue='<%# Bind("OrganizationID") %>'>
<CollapseAnimation Duration="200" Type="OutQuint" />
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td class="style6">
TechArea:
</td>
<td>
<telerik:RadTextBox ID="RadTextBox38" Runat="server" InvalidStyleDuration="100"
Text='<%# Bind("TechArea") %>' Width="200px" Skin="Hay">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="Label4" runat="server" Text="Non-Disclosure Signed"
Width="100px"></asp:Label>
</td>
<td>
<asp:CheckBox ID="Chk_nondisc" checked='<%# Bind("nondisc") %>' runat="server"
oncheckedchanged="Chk_nondisc_CheckedChanged" />
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="Label6" runat="server" Text="Non-Disclosure Signed Date"
Width="100px"></asp:Label>
</td>
<td>
<asp:Label ID="LBL_disclosure_signed" runat="server" Text='<%# Bind("disclosure_signed") %>'
Width="100px"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table ID="table3" border="0" cellpadding="1" cellspacing="2" rules="none"
style="border-collapse: collapse; background: white;" width="100%">
<tr>
<td align="left" class="style8">
AccessLevels:
</td>
<td align="left">
</td>
</tr>
<tr>
<td align="left" class="style7">
<asp:CheckBoxList ID="CHKList_AccessLevel" runat="server"
DataSourceID="SDS_AccessLevel" DataTextField="AccessLevelName"
DataValueField="AccessLevelCode"
RepeatColumns="2">
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td align="left" colspan="2">
</td>
</tr>
<tr>
<td align="left" colspan="2">
<asp:LinkButton ID="btnUpdate" runat="server"
CommandName='<%# Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'
Text='<%# Iif (TypeOf Container is GridEditFormInsertItem,"Insert", "Update") %>'>
</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</
MasterTableView>
<GroupingSettings CaseSensitive="False" />
<ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True"
ColumnsReorderMethod="Reorder" EnableRowHoverStyle="True">
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
</
telerik:RadGrid>
<
asp:SqlDataSource ID="SDS_UserInfo" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [tblUsers] WHERE [UserID] = @UserID"
InsertCommand="INSERT INTO [tblUsers] ([UserName], [Password], [Name], [OrganizationID], [AccessLevel], [DSN], [COM], [Fax], [Email], [TechArea], [ServiceID], [nondisc], [disclosure_signed]) VALUES (@UserName, @Password, @Name, @OrganizationID, @AccessLevel, @DSN, @COM, @Fax, @Email, @TechArea, @ServiceID, @nondisc, @disclosure_signed)"
SelectCommand="SELECT tblUsers.UserID, tblUsers.UserName, tblUsers.Password, tblUsers.Name, tblUsers.AccessLevel, tblUsers.DSN, tblUsers.COM, tblUsers.Fax, tblUsers.Email, tblUsers.TechArea, tblUsers.ServiceID, tblUsers.nondisc, tblUsers.disclosure_signed, tbl_Service.Service, tbl_Organizations.Organization, tblUsers.OrganizationID FROM tblUsers INNER JOIN tbl_Service ON tblUsers.ServiceID = tbl_Service.ServiceID INNER JOIN tbl_Organizations ON tblUsers.OrganizationID = tbl_Organizations.OrganizationID"
UpdateCommand="UPDATE [tblUsers] SET [UserName] = @UserName, [Password] = @Password, [Name] = @Name, [OrganizationID] = @OrganizationID, [AccessLevel] = @AccessLevel, [DSN] = @DSN, [COM] = @COM, [Fax] = @Fax, [Email] = @Email, [TechArea] = @TechArea, [ServiceID] = @ServiceID, [nondisc] = @nondisc, [disclosure_signed] = @disclosure_signed WHERE [UserID] = @UserID">
<DeleteParameters>
<asp:Parameter Name="UserID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="OrganizationID" Type="Int32" />
<asp:Parameter Name="AccessLevel" Type="Int32" />
<asp:Parameter Name="DSN" Type="String" />
<asp:Parameter Name="COM" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="TechArea" Type="String" />
<asp:Parameter Name="ServiceID" Type="Int32" />
<asp:Parameter Name="nondisc" Type="Int32" />
<asp:Parameter Name="disclosure_signed" Type="DateTime" />
<asp:Parameter Name="UserID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="OrganizationID" Type="Int32" />
<asp:Parameter Name="AccessLevel" Type="Int32" />
<asp:Parameter Name="DSN" Type="String" />
<asp:Parameter Name="COM" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="TechArea" Type="String" />
<asp:Parameter Name="ServiceID" Type="Int32" />
<asp:Parameter Name="nondisc" Type="Int32" />
<asp:Parameter Name="disclosure_signed" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_UserRoles" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DataSourceMode="DataReader"
SelectCommand="SELECT * FROM [tbl_user_role] WHERE ([FK_user] = @FK_user)">
<SelectParameters>
<asp:ControlParameter ControlID="RadGrid1" Name="FK_user"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_Service" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [tbl_Service]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_Organization" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [tbl_Organizations]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_AccessLevel" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [tbl_AccessLevels]"></asp:SqlDataSource>
</
asp:Content>
VB CODE:
Private Sub RadGrid1_EditCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand
'For Each item In RadGrid1.EditItems
' Dim itemToEdit As GridEditableItem = CType(item.EditFormItem, GridEditableItem)
' 'perform further operations
' Dim CHKList_AccessLevel1 As CheckBoxList = CType(itemToEdit.FindControl("CHKList_AccessLevel"), CheckBoxList)
'Next item
''Get the GridEditableItem of the RadGrid
'Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditFormItem)
''Access the CheckBoxList from the edit form template and store the values in string variables.
'Dim CHKList_AccessLevel1 As CheckBoxList = CType(editedItem.FindControl("AccessLevel"), CheckBoxList)
'Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
'Dim mydatatable As New DataTable
'Dim myreader As SqlDataReader
'Dim myconnection As New SqlConnection
'myconnection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
'Dim fk_user As New SqlParameter
'fk_user.ParameterName = "@FK_user"
'fk_user.Value = dataItem("UserID").Text
'Dim SelectCommand = "SELECT * FROM [tbl_user_role] WHERE ([FK_user] = @FK_user)"
'Dim mycommand As New SqlCommand
'mycommand.CommandText = SelectCommand
'mycommand.Connection = myconnection
'mycommand.Parameters.Add(fk_user)
'mycommand.Connection.Open()
'myreader = mycommand.ExecuteReader(CommandBehavior.CloseConnection)
'mydatatable.Load(myreader)
'Dim i = 0
'If mydatatable.Rows.Count > 0 Then
' 'If Not CHKList_AccessLevel1 Is Nothing Then
' For i = 0 To CHKList_AccessLevel1.Items.Count - 1
' For Each row In mydatatable.Rows
' If CHKList_AccessLevel1.Items(i).Value = mydatatable.Rows.Item(0).Item("fk_role").ToString Then
' CHKList_AccessLevel1.Items(i).Selected = True
' End If
' Next
' Next i
' 'End If
'End If
End Sub
Private Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand
End Sub
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
If e.CommandName = RadGrid.InitInsertCommandName Then '"Add new" button clicked
Dim editColumn As GridEditCommandColumn = CType(RadGrid1.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
editColumn.Visible =
False
e.Canceled =
True
'Prepare an IDictionary with the predefined values
Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
'set default checked state for checkbox inside the EditItemTemplate
newValues(
"nondisc") = False
'Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues)
ElseIf (e.CommandName = RadGrid.RebindGridCommandName AndAlso e.Item.OwnerTableView.IsItemInserted) Then
e.Canceled =
True
Else
Dim editColumn As GridEditCommandColumn = CType(RadGrid1.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
If Not editColumn.Visible Then
editColumn.Visible =
True
End If
End If
'If TypeOf e.Item Is GridEditFormItem Then
' Dim editedItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
' CHKList_AccessLevel1 = CType(editedItem.FindControl("CHKList_AccessLevel"), CheckBoxList)
'End If
'saves old values to session if needed
'If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
' Dim lbl_sign_date As Label = CType(e.Item.FindControl("LBL_disclosure_signed"), Label)
' Session("savedOldValue") = lbl_sign_date.Text
'End If
End Sub
Public Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
'set delete confim
Dim UserName As String = dataItem("UserName").Text
Dim button As LinkButton = CType(dataItem("Delete").Controls(0), LinkButton)
button.Attributes(
"onclick") = "return confirm('Are you sure you want to delete " & UserName & " User from database?')"
End If
'set checkbox list for access level
If (TypeOf (e.Item) Is GridEditableItem And e.Item.IsInEditMode) Then
Dim CHKList_AccessLevel As CheckBoxList = CType(e.Item, GridEditFormItem)("AccessLevel").FindControl("CHKList_AccessLevel")
'Dim dataItem As GridDataItem = CType(e.Item, GridEditableItem)
Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditFormItem)
'Dim CHKList_AccessLevel As CheckBoxList = CType(sender, CheckBoxList)
Dim item As GridEditFormItem = CType(CHKList_AccessLevel.NamingContainer, GridEditFormItem)
Dim mydatatable As New DataTable
Dim myreader As SqlDataReader
Dim myconnection As New SqlConnection
myconnection.ConnectionString = ConfigurationManager.ConnectionStrings(
"ConnectionString").ConnectionString
Dim fk_user As New SqlParameter
fk_user.ParameterName =
"@FK_user"
fk_user.Value = editedItem(
"UserID").Text
Dim SelectCommand = "SELECT * FROM [tbl_user_role] WHERE ([FK_user] = @FK_user)"
Dim mycommand As New SqlCommand
mycommand.CommandText = SelectCommand
mycommand.Connection = myconnection
mycommand.Parameters.Add(fk_user)
mycommand.Connection.Open()
myreader = mycommand.ExecuteReader(CommandBehavior.CloseConnection)
mydatatable.Load(myreader)
Dim i = 0
If mydatatable.Rows.Count > 0 Then
'If Not CHKList_AccessLevel Is Nothing Then
For i = 0 To CHKList_AccessLevel.Items.Count - 1
For Each row In mydatatable.Rows
If CHKList_AccessLevel.Items(i).Value = mydatatable.Rows.Item(0).Item("fk_role").ToString Then
CHKList_AccessLevel.Items(i).Selected =
True
End If
Next
Next i
'End If
End If
End If
End Sub
Protected Sub RadGrid1_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles RadGrid1.ItemDeleted
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
DisplayMessage(
True, "Record " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID").ToString() + " cannot be deleted. Reason: " + e.Exception.Message)
Else
DisplayMessage(
False, "Record " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID").ToString() + " deleted")
End If
End Sub
Protected Sub RadGrid1_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles RadGrid1.ItemInserted
If Not e.Exception Is Nothing Then
e.ExceptionHandled =
True
e.KeepInInsertMode =
True
DisplayMessage(
True, "User cannot be inserted. Reason: " + e.Exception.Message)
Else
DisplayMessage(
False, "User inserted")
End If
End Sub
Protected Sub RadGrid1_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles RadGrid1.ItemUpdated
If Not e.Exception Is Nothing Then
e.KeepInEditMode =
True
e.ExceptionHandled =
True
DisplayMessage(
True, "User item " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID").ToString() + " cannot be updated. Reason: " + e.Exception.Message)
Else
DisplayMessage(
False, "User item " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID").ToString() + " updated")
End If
End Sub
Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender
If (Not Page.IsPostBack) Then
'RadGrid1.EditIndexes.Add(0)
RadGrid1.Rebind()
End If
End Sub
Private Sub DisplayMessage(ByVal isError As Boolean, ByVal text As String)
Dim label As Label = IIf(isError, Me.Label1, Me.Label2)
label.Text = text
End Sub
Protected Sub Chk_nondisc_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
'grab checkbox from template form and reset signed date value
Dim box As CheckBox = CType(sender, CheckBox)
Dim item As GridEditFormItem = CType(box.NamingContainer, GridEditFormItem)
Dim lbl_signed As Label = CType(item.FindControl("LBL_disclosure_signed"), Label)
Dim signed_date As Date = Now()
If box.Checked Then
lbl_signed.Text = signed_date
Else
lbl_signed.Text =
Nothing
End If
End Sub
Public Function Check_ClickedAccessLevel(ByVal sender As Object, ByVal e As EventArgs)
' ''grab checkbox from template form and reset signed date value
''Dim CHKList_AccessLevel As CheckBoxList = CType(sender, CheckBoxList)
''Dim item As GridEditFormItem = CType(CHKList_AccessLevel.NamingContainer, GridEditFormItem)
' '' Make sure a control was found.
''If Not CHKList_AccessLevel Is Nothing Then
'' ' Iterate through the Items collection of CheckBoxList
'' ' control and capture the selected items.
'' Dim i As Integer
'' For SDS_UserRoles.
'' For i = 0 To CHKList_AccessLevel.Items.Count - 1
'' If CHKList_AccessLevel.Items(i).Selected Then
'' CHKList_AccessLevel.Items(i).Selected = True
'' End If
'' Next i
'' Next
'' 'Return StrAccesslevel
''Else
'' ' Display an error message.
'' 'StrAccesslevel = "Unable to find CheckBoxList control."
'' 'lbltest.Text = message
''End If
'Dim CHKList_AccessLevel1 As CheckBoxList = CType(sender, CheckBoxList)
'Dim item As GridEditFormItem = CType(CHKList_AccessLevel1.NamingContainer, GridEditFormItem)
'CHKList_AccessLevel1.DataSource = SDS_UserRoles
'CHKList_AccessLevel1.DataValueField = "fk_role"
'CHKList_AccessLevel1.DataBind()
End Function
Private Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
''first reference the edited grid item through the NamingContainer attribute
'Dim editedItem As GridEditableItem = CType(CType(source, CheckBoxList).NamingContainer, GridEditableItem)
''grab checkbox from template form and reset signed date value
'Dim CHKList_AccessLevel1 As CheckBoxList = CType(editedItem.FindControl("CHKList_AccessLevel"), CheckBoxList)
'Dim Gitem As GridEditFormItem = CType(CHKList_AccessLevel1.NamingContainer, GridEditFormItem)
' ''set checkboxlist values
'For Each Item As ListItem In CHKList_AccessLevel1.Items
' If Item.Selected Then
' SDS_UserRoles.Insert()
' Else
' SDS_UserRoles.Delete()
' End If
'Next
End Sub
Protected Sub CHKList_AccessLevel_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
''first reference the edited grid item through the NamingContainer attribute
'Dim editedItem As GridEditableItem = CType(CType(sender, CheckBoxList).NamingContainer, GridEditableItem)
''grab checkbox from template form and reset signed date value
'Dim CHKList_AccessLevel1 As CheckBoxList = CType(editedItem.FindControl("CHKList_AccessLevel"), CheckBoxList)
''Dim Gitem As GridEditFormItem = CType(CHKList_AccessLevel1.NamingContainer, GridEditFormItem)
' ''set checkboxlist values
'For Each Item As ListItem In CHKList_AccessLevel1.Items
' If Item.Selected Then
' Dim FK_user1 As Integer
' Dim Fk_role1 As Integer
' Dim CreateDate1 As Date
' Dim checkvalue As String = CHKList_AccessLevel1.SelectedValue
' SDS_UserRoles.InsertParameters.Add(FK_user1, Session("UserID"))
' SDS_UserRoles.InsertParameters.Add(Fk_role1, checkvalue)
' SDS_UserRoles.InsertParameters.Add(CreateDate1, Now())
' SDS_UserRoles.Insert()
' Else
' SDS_UserRoles.Delete()
' End If
'Next
End Sub