This is a migrated thread and some comments may be shown as answers.

How to access child gridview row

9 Answers 245 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Atul Katiyar
Top achievements
Rank 1
Atul Katiyar asked on 09 Jul 2009, 04:49 AM
Hi,

I am working with Telerik Self-referencing RadGridView. RadGridView displays hierarchial manner. When a record in the RadGridView is expanded, I intend to make a database query via WCF service. I then wish to populate the parent record (the one being expanded) with the newly fetched child record. Hence the ObservableCollection<> of records are created at run-time when the user expands particular record of the grid.
I could successfuly fetch the base record (records at level 0) and display it. Root record has a dummy child which is refreshed when the user expands the root record. Once the child records are available, I change the root record's data binding with the new child record (root.ChildNode = childNodeCollection to build the hierarchy). However, when I change the child record of the parent (parent.ChildNode = null initially and then later on set to childNodeCollection), I want to refresh the grid view. How do i accomplish this ? Invoking RadGridView.ReBind() collapses all the currently expanded rows which I want to avoid!

9 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 15 Jul 2009, 01:52 PM
Hi Atul Katiyar,

You can use the following methods to automatically re-expand all previously expanded rows after rebind:

List<int> expandedRowsIndices = new List<int>();  
 
private void Button_Click(object sender, RoutedEventArgs e)  
{  
    this.SaveExpandedRows();  
    this.RadGridView1.Rebind();  
    this.ExpandRows();  
}  
 
private void SaveExpandedRows()  
{  
    this.expandedRowsIndices.Clear();  
 
    foreach (var item in this.RadGridView1.Records)  
    {  
        var expandableItem = item as ExpandableDataRecord;  
 
        if (expandableItem != null && expandableItem.IsExpanded)  
            this.expandedRowsIndices.Add(expandableItem.DataSourceIndex);  
    }  
}  
 
private void ExpandRows()  
{  
    foreach (var item in this.expandedRowsIndices)  
    {  
        var expandableItem = this.RadGridView1.Records[item] as ExpandableDataRecord;  
 
        if (expandableItem != null)  
            expandableItem.IsExpanded = true;  
    }  

First we determine which rows were expanded and save the results. After that we rebind and finally use the data from SaveExpandedRows to expand the rows after the grid is refreshed.

Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Charles Trig
Top achievements
Rank 1
answered on 14 Sep 2009, 12:29 AM
I have a similar problem, but I can't figure out how to apply the fix you have here to my situation. I have  a RadGridWindow with LinqDataSources to pull in the various datasets the client wants. When saving a new entry or updating a record in a Linq, the Grid collapses. Any help is greatly appreciated! Here is the code; how can we stop the grid from collasping and keeping the selected client row open?

DRAMembers.ascx:

<telerik:RadGrid ID="RadGridDRAMembers" runat="server" AllowPaging="True" AllowSorting="True"
    DataSourceID="LinqUsers" OnItemCreated="RadGridDRAMembers_ItemCreated" GridLines="None"
    Skin="Inox" AutoGenerateColumns="False" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
    AllowAutomaticUpdates="True" ShowStatusBar="True">
    <PagerStyle Mode="Slider" />
    <MasterTableView DataKeyNames="UserID" DataSourceID="LinqUsers" Name="UserTable"
        CommandItemDisplay="Top">
        <DetailTables>
            <telerik:GridTableView runat="server" DataSourceID="LinqDRAMembers" DataKeyNames="UserID,DRAMemberID"
                Name="MemberTable"
                Caption="&lt;font size=&quot;4&quot;&gt;&lt;strong&gt;Member Information&lt;/strong&gt;&lt;/font&gt;"
                HierarchyDefaultExpanded="True">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="UserID" MasterKeyField="UserID" />
                </ParentTableRelation>
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn Resizable="False">
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn UniqueName="TemplateEditMemberColumn" Visible="true">
                        <ItemTemplate>
                            <asp:Button ID="EditMember" Text="Edit" runat="server" CommandName="EditMember">
                            </asp:Button>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="DRAMemberID" DataType="System.Int32" HeaderText="Member ID"
                        ReadOnly="true" SortExpression="DRAMemberID" UniqueName="DRAMemberID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="UserID" DataType="System.Int32" HeaderText="User ID"
                        ReadOnly="true" SortExpression="UserID" UniqueName="UserID" Visible="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataSourceID="LinqStatus" DataField="Status" DataType="System.Int32"
                        SortExpression="Status" HeaderText="Status" UniqueName="Status" ListTextField="StatusDescription"
                        ListValueField="DRAStatusID" EnableEmptyListItem="True">
                    </telerik:GridDropDownColumn>
                    <telerik:GridBoundColumn DataField="SSN" HeaderText="SSN" ItemStyle-Wrap="False"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" SortExpression="SSN"
                        UniqueName="SSN" DataFormatString="{0:000-00-0000}">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataSourceID="XmlGender" ListTextField="Text" ListValueField="Value"
                        DataField="Sex" HeaderText="Sex" SortExpression="Sex" DataType="System.String"
                        UniqueName="Sex" ItemStyle-Wrap="false" EnableEmptyListItem="True">
                        <ItemStyle Wrap="False"></ItemStyle>
                    </telerik:GridDropDownColumn>
                    <telerik:GridDateTimeColumn DataField="BirthDate" DataType="System.DateTime" HeaderText="Birth Date"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}"
                        PickerType="DatePicker" SortExpression="BirthDate" UniqueName="BirthDate">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn DataField="MotherMaidenName" DataType="System.String" HeaderText="Mother Maiden Name"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" SortExpression="MotherMaidenName"
                        UniqueName="MotherMaidenName">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="PlanStartDate" DataType="System.DateTime"
                        HeaderText="Plan Start Date" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                        DataFormatString="{0:d}" PickerType="DatePicker" SortExpression="PlanStartDate"
                        UniqueName="PlanStartDate">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridDateTimeColumn>
                    <telerik:GridDropDownColumn DataSourceID="LinqConsultants" ListTextField="DisplayName"
                        ListValueField="UserID" DataField="Consultant" HeaderText="Consultant" SortExpression="Consultant"
                        DataType="System.Int32" UniqueName="Consultant" ItemStyle-Wrap="false" EnableEmptyListItem="True">
                        <ItemStyle Wrap="False"></ItemStyle>
                    </telerik:GridDropDownColumn>
                    <telerik:GridDropDownColumn DataSourceID="LinqQualityControl" ListTextField="DisplayName"
                        ListValueField="UserID" DataField="QualityControl" HeaderText="Quality Control"
                        SortExpression="QualityControl" DataType="System.Int32" UniqueName="QualityControl"
                        ItemStyle-Wrap="false" EnableEmptyListItem="True">
                        <ItemStyle Wrap="False"></ItemStyle>
                    </telerik:GridDropDownColumn>
                    <telerik:GridBoundColumn DataField="Phone" DataFormatString="{0:(###) ###-####}"
                        SortExpression="Phone" ItemStyle-Wrap="False" HeaderText="Phone" UniqueName="Phone">
                        <ItemStyle Wrap="False"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Cell" DataFormatString="{0:(###) ###-####}" SortExpression="Cell"
                        ItemStyle-Wrap="False" HeaderText="Cell" UniqueName="Cell">
                        <ItemStyle Wrap="False"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataField="ModifiedBy" DataType="System.Int32" HeaderText="Modified By"
                        HeaderStyle-HorizontalAlign="Center" ReadOnly="true" ItemStyle-HorizontalAlign="Center"
                        SortExpression="ModifiedBy" UniqueName="ModifiedBy" HeaderStyle-Wrap="false"
                        ItemStyle-Wrap="false" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                        ListValueField="UserID">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridDropDownColumn>
                    <telerik:GridBoundColumn DataField="ModifiedDate" DataType="System.DateTime" HeaderText="Modified Date"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" SortExpression="ModifiedDate"
                        HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ReadOnly="true" UniqueName="ModifiedDate"
                        Visible="false">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataField="CreatedBy" ReadOnly="true" DataType="System.Int32"
                        HeaderText="Created By" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false"
                        ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center" SortExpression="CreatedBy"
                        UniqueName="CreatedBy" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                        ListValueField="UserID">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridDropDownColumn>
                    <telerik:GridBoundColumn DataField="CreatedDate" DataType="System.DateTime" HeaderText="Created Date"
                        ReadOnly="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                        SortExpression="CreatedDate" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"
                        UniqueName="CreatedDate" Visible="false">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                </Columns>
                <DetailTables>
                    <telerik:GridTableView runat="server" DataKeyNames="DRAMemberAddressID" DataSourceID="LinqDRAMemberAddresses"
                        Name="AddressesTable" CommandItemDisplay="Top" Caption="&lt;font size=&quot;4&quot;&gt;&lt;strong&gt;Addresses&lt;/strong&gt;&lt;/font&gt;">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="DRAMemberID" MasterKeyField="DRAMemberID" />
                        </ParentTableRelation>
                        <RowIndicatorColumn Visible="False">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Resizable="False" Visible="False">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <CommandItemTemplate>
                            <asp:Button ID="btnNewAddress" Height="30px" runat="server" ToolTip="This adds member address record"
                                Text="New Address" />
                        </CommandItemTemplate>
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="TemplateEditAddressColumn" Visible="true">
                                <ItemTemplate>
                                    <asp:Button ID="EditAddress" Text="Edit" runat="server" CommandName="EditAddress">
                                    </asp:Button>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn ConfirmText="Delete this address?" ConfirmDialogType="RadWindow"
                                ConfirmTitle="Delete" ButtonType="imagebutton" CommandName="Delete" Text="Delete"
                                UniqueName="DeleteAddress" Visible="False">
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridButtonColumn>
                            <telerik:GridBoundColumn DataField="DRAMemberAddressID" HeaderText="Member Address ID"
                                ReadOnly="true" SortExpression="DRAMemberAddressID" UniqueName="DRAMemberAddressID"
                                Visible="False" DataType="System.Int32">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="DRAMemberID" HeaderText="Member ID" SortExpression="DRAMemberID"
                                ReadOnly="true" UniqueName="DRAMemberID" Visible="False" DataType="System.Int32">
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="AddressType" HeaderText="Address Type" DataType="System.Int32"
                                SortExpression="AddressType" DataSourceID="LinqAddressTypes" UniqueName="AddressType"
                                ListTextField="AddressDescription" ListValueField="DRAAddressTypeID" DropDownControlType="RadComboBox"
                                EnableEmptyListItem="True">
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="Address1" HeaderText="Address1" SortExpression="Address1"
                                UniqueName="Address1">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Address2" HeaderText="Address2" SortExpression="Address2"
                                UniqueName="Address2">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                                UniqueName="City">
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataSourceID="LinqRegions" DataField="State" HeaderText="State"
                                UniqueName="State" ListTextField="RegionDescription" ListValueField="RegionAbbreviation"
                                EnableEmptyListItem="True">
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="PostalCode" HeaderText="Postal Code" SortExpression="PostalCode"
                                UniqueName="PostalCode">
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="ModifiedBy" DataType="System.Int32" HeaderText="Modified By"
                                HeaderStyle-HorizontalAlign="Center" ReadOnly="true" ItemStyle-HorizontalAlign="Center"
                                SortExpression="ModifiedBy" UniqueName="ModifiedBy" HeaderStyle-Wrap="false"
                                ItemStyle-Wrap="false" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                                ListValueField="UserID">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="ModifiedDate" DataType="System.DateTime" HeaderText="Modified Date"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" SortExpression="ModifiedDate"
                                HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ReadOnly="true" UniqueName="ModifiedDate"
                                Visible="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="CreatedBy" ReadOnly="true" DataType="System.Int32"
                                HeaderText="Created By" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false"
                                ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center" SortExpression="CreatedBy"
                                UniqueName="CreatedBy" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                                ListValueField="UserID">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="CreatedDate" DataType="System.DateTime" HeaderText="Created Date"
                                ReadOnly="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                SortExpression="CreatedDate" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"
                                UniqueName="CreatedDate" Visible="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                    <telerik:GridTableView runat="server" DataKeyNames="DRAMemberLoanID" DataSourceID="LinqDRAMemberLoans"
                        Name="LoansTable" CommandItemDisplay="Top" Caption="&lt;font size=&quot;4&quot;&gt;&lt;strong&gt;Credit Information&lt;/strong&gt;&lt;/font&gt;"
                        PageSize="30">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="DRAMemberID" MasterKeyField="DRAMemberID" />
                        </ParentTableRelation>
                        <RowIndicatorColumn Visible="False">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Resizable="False" Visible="False">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <CommandItemTemplate>
                            <asp:Button ID="btnNewLoan" Height="30px" runat="server" ToolTip="This adds a new member creditor information"
                                Text="New Creditor" />
                            <asp:Button ID="btnReport" Height="30px" runat="server" Text="Full Analysis Report"
                                ToolTip="Generate Full Analysis Report" />
                        </CommandItemTemplate>
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="TemplateEditLoanColumn" Visible="true">
                                <ItemTemplate>
                                    <asp:Button ID="EditLoan" Text="Edit" runat="server" CommandName="EditLoan"></asp:Button>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn ConfirmText="Delete this loan?" ConfirmDialogType="RadWindow"
                                ConfirmTitle="Delete" ButtonType="imagebutton" CommandName="Delete" Text="Delete"
                                UniqueName="DeleteLoan" Visible="False">
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridButtonColumn>
                            <telerik:GridBoundColumn DataField="DRAMemberLoanID" DataType="System.Int32" HeaderText="Member Loan ID"
                                ReadOnly="true" SortExpression="DRAMemberLoanID" UniqueName="DRAMemberLoanID"
                                Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="DRAMemberID" DataType="System.Int32" HeaderText="Member ID"
                                ReadOnly="true" SortExpression="DRAMemberID" UniqueName="DRAMemberID" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Seq" HeaderText="Seq" SortExpression="Seq" UniqueName="Seq"
                                DataType="System.Int16" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="DebtType" HeaderText="Debt Type" SortExpression="DebtType"
                                DataSourceID="LinqDebtTypes" ListTextField="DebtTypeDescript" UniqueName="DebtType"
                                ListValueField="DRADebtType" DropDownControlType="RadComboBox" EnableEmptyListItem="True">
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="Creditor" HeaderText="Creditor" SortExpression="Creditor"
                                UniqueName="Creditor">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="AcctNo" HeaderText="Acct No" SortExpression="AcctNo"
                                ItemStyle-Wrap="False" UniqueName="AcctNo">
                                <ItemStyle Wrap="False"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Balance" DataType="System.Decimal" HeaderText="Balance"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="Balance"
                                ItemStyle-Wrap="False" DataFormatString="{0:c}" UniqueName="Balance">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Rate" DataType="System.Decimal" HeaderText="Rate"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="Rate"
                                ItemStyle-Wrap="False" DataFormatString="{0:p}" UniqueName="Rate">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Payment" DataType="System.Decimal" HeaderText="Payment"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="Payment"
                                ItemStyle-Wrap="False" DataFormatString="{0:c}" UniqueName="Payment">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="RevisedBalance" DataType="System.Decimal" HeaderText="Revised Balance"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="RevisedBalance"
                                ItemStyle-Wrap="False" DataFormatString="{0:c}" UniqueName="RevisedBalance">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="RevisedRate" DataType="System.Decimal" HeaderText="Revised Rate"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="RevisedRate"
                                ItemStyle-Wrap="False" DataFormatString="{0:p}" UniqueName="RevisedRate">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="RevisedPayment" DataType="System.Decimal" HeaderText="Revised Payment"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="RevisedPayment"
                                ItemStyle-Wrap="False" DataFormatString="{0:c}" UniqueName="RevisedPayment">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="MinimumPayment" DataType="System.Decimal" HeaderText="Minimum Payment"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="MinimumPayment"
                                ItemStyle-Wrap="False" DataFormatString="{0:c}" UniqueName="MinimumPayment">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="PaymentsAnnually" DataType="System.Int16" HeaderText="Payments Annually"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="PaymentsAnnually"
                                ItemStyle-Wrap="False" UniqueName="PaymentsAnnually">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="UnpaidPercentage" DataType="System.Decimal" HeaderText="Unpaid Percentage"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" SortExpression="UnpaidPercentage"
                                ItemStyle-Wrap="False" DataFormatString="{0:p}" UniqueName="UnpaidPercentage">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="ModifiedBy" DataType="System.Int32" HeaderText="Modified By"
                                HeaderStyle-HorizontalAlign="Center" ReadOnly="true" ItemStyle-HorizontalAlign="Center"
                                SortExpression="ModifiedBy" UniqueName="ModifiedBy" HeaderStyle-Wrap="false"
                                ItemStyle-Wrap="false" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                                ListValueField="UserID">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="ModifiedDate" DataType="System.DateTime" HeaderText="Modified Date"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" SortExpression="ModifiedDate"
                                HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ReadOnly="true" UniqueName="ModifiedDate"
                                Visible="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="CreatedBy" ReadOnly="true" DataType="System.Int32"
                                HeaderText="Created By" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false"
                                ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center" SortExpression="CreatedBy"
                                UniqueName="CreatedBy" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                                ListValueField="UserID">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="CreatedDate" DataType="System.DateTime" HeaderText="Created Date"
                                ReadOnly="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                SortExpression="CreatedDate" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"
                                UniqueName="CreatedDate" Visible="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                    <telerik:GridTableView runat="server" DataKeyNames="DRAMemberNoteID" DataSourceID="LinqDRAMemberNotes"
                        Name="NotesTable" CommandItemDisplay="Top" Caption="&lt;font size=&quot;4&quot;&gt;&lt;strong&gt;Notes&lt;/strong&gt;&lt;/font&gt;"
                        PageSize="20">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="DRAMemberID" MasterKeyField="DRAMemberID" />
                        </ParentTableRelation>
                        <RowIndicatorColumn Visible="False">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Resizable="False" Visible="False">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <CommandItemTemplate>
                            <asp:Button ID="btnNewNote" Height="30px" runat="server" ToolTip="This adds a new note to the current member"
                                Text="New Note" />
                        </CommandItemTemplate>
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="TemplateEditNoteColumn" Visible="false">
                                <ItemTemplate>
                                    <asp:Button ID="EditNote" Text="Edit" runat="server" CommandName="EditNote"></asp:Button>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="DRAMemberNoteID" DataType="System.Int32" HeaderText="Member Note ID"
                                ReadOnly="true" SortExpression="DRAMemberNoteID" UniqueName="DRAMemberNoteID"
                                Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="DRAMemberID" DataType="System.Int32" HeaderText="Member ID"
                                ReadOnly="true" SortExpression="DRAMemberID" UniqueName="DRAMemberID" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridHTMLEditorColumn DataField="Note" HeaderText="Note" SortExpression="Note"
                                HeaderStyle-HorizontalAlign="Center" UniqueName="Note" ItemStyle-Wrap="True">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle Wrap="True"></ItemStyle>
                            </telerik:GridHTMLEditorColumn>
                            <telerik:GridBoundColumn DataField="CallBackDate" DataType="System.DateTime" HeaderText="Callback Date"
                                ReadOnly="true" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-HorizontalAlign="Center" SortExpression="CallBackDate" UniqueName="CallBackDate">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataSourceID="LinqActivityCodes" DataField="ActivityCodeID"
                                ReadOnly="true" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" DataType="System.Int32"
                                HeaderText="Activity" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                SortExpression="Activity" UniqueName="ActivityCodeID" ListTextField="ActivityDescription"
                                ListValueField="ActivityCodeID" EnableEmptyListItem="True">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridDropDownColumn DataField="ModifiedBy" DataType="System.Int32" HeaderText="Modified By"
                                HeaderStyle-HorizontalAlign="Center" ReadOnly="true" ItemStyle-HorizontalAlign="Center"
                                SortExpression="ModifiedBy" UniqueName="ModifiedBy" HeaderStyle-Wrap="false"
                                ItemStyle-Wrap="false" Visible="false" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                                ListValueField="UserID">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="ModifiedDate" DataType="System.DateTime" HeaderText="Modified Date"
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" SortExpression="ModifiedDate"
                                HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ReadOnly="true" UniqueName="ModifiedDate"
                                Visible="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="CreatedBy" ReadOnly="true" DataType="System.Int32"
                                HeaderText="Created By" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false"
                                ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center" SortExpression="CreatedBy"
                                UniqueName="CreatedBy" Visible="true" DataSourceID="LinqEmployees" ListTextField="DisplayName"
                                ListValueField="UserID">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="CreatedDate" DataType="System.DateTime" HeaderText="Created Date"
                                ReadOnly="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                SortExpression="CreatedDate" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"
                                UniqueName="CreatedDate" Visible="true">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
            </telerik:GridTableView>
        </DetailTables>
        <RowIndicatorColumn Visible="False">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn Resizable="False">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridTemplateColumn UniqueName="TemplateEditUserColumn" Visible="true">
                <ItemTemplate>
                    <asp:Button ID="EditUser" Text="Edit" runat="server" CommandName="EditUser"></asp:Button>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="UserID" DataType="System.Int32" HeaderText="User ID"
                ReadOnly="True" SortExpression="UserID" UniqueName="UserID" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Username" HeaderText="Username" SortExpression="Username"
                UniqueName="Username" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" SortExpression="FirstName"
                UniqueName="FirstName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" SortExpression="LastName"
                UniqueName="LastName">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn DataField="IsSuperUser" DataType="System.Boolean" HeaderText="IsSuperUser"
                SortExpression="IsSuperUser" UniqueName="IsSuperUser" Visible="False">
            </telerik:GridCheckBoxColumn>
            <telerik:GridBoundColumn DataField="AffiliateId" DataType="System.Int32" HeaderText="AffiliateId"
                SortExpression="AffiliateId" UniqueName="AffiliateId" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="DisplayName" HeaderText="Display Name" SortExpression="DisplayName"
                UniqueName="DisplayName" Visible="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Email" HeaderText="Email" SortExpression="Email"
                UniqueName="Email">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn DataField="UpdatePassword" DataType="System.Boolean"
                HeaderText="UpdatePassword" SortExpression="UpdatePassword" UniqueName="UpdatePassword"
                Visible="False">
            </telerik:GridCheckBoxColumn>
        </Columns>
        <CommandItemTemplate>
            <asp:Button ID="btnNewUser" Height="30px" runat="server" ToolTip="This adds a registered user"
                Text="Add Registered User" />
        </CommandItemTemplate>
        <EditFormSettings>
            <PopUpSettings ScrollBars="None"></PopUpSettings>
        </EditFormSettings>
    </MasterTableView>
    <GroupingSettings CaseSensitive="False" />
    <ClientSettings>
        <Selecting AllowRowSelect="true" />
    </ClientSettings>
    <FilterMenu Skin="Inox" EnableTheming="True">
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
    </FilterMenu>
</telerik:RadGrid>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Inox" Behaviors="Resize, Close, Move"
    KeepInScreenBounds="True">
    <Windows>
        <telerik:RadWindow ID="DRAAnalysisReport" Title="Full Analysis Report" runat="server"
            Height="500px" Width="800px" DestroyOnClose="True" ReloadOnShow="true" Modal="true"
            ShowContentDuringLoad="False" Behavior="None" Behaviors="Maximize,Close,Move">
        </telerik:RadWindow>
        <telerik:RadWindow ID="EditUser" Title="Registered User" runat="server" Height="380px"
            Width="530px" DestroyOnClose="False" Behavior="None" Behaviors="None" ReloadOnShow="true"
            Modal="true" ShowContentDuringLoad="False">
        </telerik:RadWindow>
        <telerik:RadWindow ID="EditAppSettings" Title="Global Application Settings" runat="server"
            Height="500px" Width="600px" DestroyOnClose="False" ReloadOnShow="true" Modal="true"
            ShowContentDuringLoad="False">
        </telerik:RadWindow>
        <telerik:RadWindow ID="EditNote" Title="Member Note" runat="server" Height="520px"
            Width="800px" DestroyOnClose="False" Behavior="None" Behaviors="None" ReloadOnShow="true"
            Modal="true" ShowContentDuringLoad="False">
        </telerik:RadWindow>
        <telerik:RadWindow ID="EditAddress" Title="Member Address" runat="server" Height="350px"
            Width="430px" DestroyOnClose="False" Behavior="None" Behaviors="None" ReloadOnShow="true"
            Modal="true" ShowContentDuringLoad="False">
        </telerik:RadWindow>
        <telerik:RadWindow ID="EditMember" Title="Member Information" runat="server" Height="400px"
            Width="780px" DestroyOnClose="False" Behavior="None" Behaviors="Maximize" ReloadOnShow="true"
            Modal="true" ShowContentDuringLoad="False">
        </telerik:RadWindow>
        <telerik:RadWindow ID="EditLoan" Title="Member Creditor" runat="server" Height="440px"
            Width="760px" DestroyOnClose="False" Behavior="None" Behaviors="None" ReloadOnShow="true"
            Modal="true" ShowContentDuringLoad="False">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<asp:LinqDataSource ID="LinqUsers" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    TableName="Users" EnableInsert="True" EnableUpdate="True">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDRAMembers" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    EnableInsert="True" EnableUpdate="True" TableName="DRAMembers" Where="UserID == @UserID">
    <WhereParameters>
        <asp:SessionParameter Name="UserID" SessionField="UserID" Type="Int32" />
    </WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDRAMemberAddresses" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="DRAMemberAddresses"
    Where="DRAMemberID == @DRAMemberID">
    <WhereParameters>
        <asp:SessionParameter Name="DRAMemberID" SessionField="DRAMemberID" Type="Int32" />
    </WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDRAMemberLoans" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="DRAMemberLoans"
    Where="DRAMemberID == @DRAMemberID">
    <WhereParameters>
        <asp:SessionParameter Name="DRAMemberID" SessionField="DRAMemberID" Type="Int32" />
    </WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDRAMemberNotes" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    EnableInsert="True" TableName="DRAMemberNotes" Where="DRAMemberID == @DRAMemberID"
    OrderBy="CreatedDate desc" EnableUpdate="True">
    <WhereParameters>
        <asp:SessionParameter Name="DRAMemberID" SessionField="DRAMemberID" Type="Int32" />
    </WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDebtTypes" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    TableName="DRADebtTypes">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqActivityCodes" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    TableName="DRAActivityCodes">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqAddressTypes" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    TableName="DRAAddressTypes">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqRegions" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    TableName="DRARegions">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqStatus" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    TableName="DRAStatus">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqConsultants" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    Select="new (UserID, DisplayName)" TableName="Users">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqQualityControl" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    Select="new (UserID, DisplayName)" TableName="Users">
</asp:LinqDataSource>
<asp:XmlDataSource ID="XmlGender" runat="server" DataFile="Sex.xml"></asp:XmlDataSource>
<asp:LinqDataSource ID="LinqEmployees" runat="server" ContextTypeName="DRAMembers.DRAMembersDataContext"
    Select="new (UserID, DisplayName)" TableName="Users">
</asp:LinqDataSource>


If you need the vb file source:
DRAMembers.ascx.vb:

Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq

Imports DotNetNuke
Imports DotNetNuke.Security
Imports DotNetNuke.Security.PortalSecurity
Imports DRAMembers
Imports Telerik.Web.UI

Namespace DotNetNuke.Modules.DRAMembers

    Partial Class ViewDRAMembers
        Inherits DotNetNuke.Entities.Modules.PortalModuleBase

        Private _db As New DRAMembersDataContext
        Private _CurrentUserID As Int32 = 0
        Private _CurrentDRAMemberID As Int32 = 0

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Try
                If Not IsPostBack Then
                    SetGridPermissions()
                    If IsInRole("Administrators") Or IsInRole("Managers") Then
                        Dim pagePath As String = Me.ResolveUrl("AppSettings.aspx")
                        Me.btnSettings.Attributes("href") = "#"
                        Me.btnSettings.Attributes("onclick") = [String].Format("return ShowAppSettingsForm('{0}');", pagePath)
                        Me.btnSettings.Visible = True
                    End If
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub RadGridDRAMembers_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridDRAMembers.ItemCreated
            Try
                If TypeOf e.Item Is GridDataItem Then
                    Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
                    Dim editButton As Button
                    If _CurrentDRAMemberID > 0 Then
                        editButton = DirectCast(e.Item.FindControl("EditAddress"), Button)
                        If Not editButton Is Nothing Then
                            Dim pagePath As String = Me.ResolveUrl("EditAddress.aspx")
                            editButton.Attributes("href") = "#"
                            editButton.Attributes("onclick") = [String].Format("return ShowAddressForm('{0}','{1}','{2}');", _CurrentDRAMemberID, e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("DRAMemberAddressID"), pagePath)
                        End If
                        editButton = DirectCast(e.Item.FindControl("EditLoan"), Button)
                        If Not editButton Is Nothing Then
                            Dim pagePath As String = Me.ResolveUrl("EditLoan.aspx")
                            editButton.Attributes("href") = "#"
                            editButton.Attributes("onclick") = [String].Format("return ShowLoanForm('{0}','{1}','{2}');", _CurrentDRAMemberID, e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("DRAMemberLoanID"), pagePath)
                        End If
                        editButton = DirectCast(e.Item.FindControl("EditNote"), Button)
                        If Not editButton Is Nothing Then
                            Dim pagePath As String = Me.ResolveUrl("EditNote.aspx")
                            editButton.Attributes("href") = "#"
                            editButton.Attributes("onclick") = [String].Format("return ShowNoteForm('{0}','{1}','{2}');", _CurrentDRAMemberID, e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("DRAMemberNoteID"), pagePath)
                        End If
                        editButton = DirectCast(e.Item.FindControl("EditMember"), Button)
                        If Not editButton Is Nothing Then
                            Dim pagePath As String = Me.ResolveUrl("EditMember.aspx")
                            editButton.Attributes("href") = "#"
                            editButton.Attributes("onclick") = [String].Format("return ShowMemberForm('{0}','{1}','{2}');", _CurrentUserID, e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("DRAMemberID"), pagePath)
                        End If
                    Else
                        editButton = DirectCast(e.Item.FindControl("EditUser"), Button)
                        If Not editButton Is Nothing Then
                            Dim pagePath As String = Me.ResolveUrl("EditUser.aspx")
                            editButton.Attributes("href") = "#"
                            editButton.Attributes("onclick") = [String].Format("return ShowUserForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID"), pagePath)
                        End If
                    End If
                ElseIf TypeOf e.Item Is GridCommandItem Then
                    Dim commandButton As Button
                    commandButton = DirectCast(e.Item.FindControl("btnNewUser"), Button)
                    If Not commandButton Is Nothing AndAlso commandButton.ID = "btnNewUser" Then
                        Dim pagePath As String = Me.ResolveUrl("EditUser.aspx")
                        commandButton.Attributes("href") = "#"
                        commandButton.Attributes("onclick") = [String].Format("return ShowUserForm('{0}','{1}');", 0, pagePath)
                        If Not IsInRole("Administrators") And Not IsInRole("Managers") And Not IsInRole("Processing") Then
                            commandButton.Visible = False
                        End If
                    End If
                    commandButton = DirectCast(e.Item.FindControl("btnNewNote"), Button)
                    If Not commandButton Is Nothing AndAlso commandButton.ID = "btnNewNote" Then
                        If _CurrentDRAMemberID > 0 Then
                            Dim pagePath As String = Me.ResolveUrl("EditNote.aspx")
                            commandButton.Attributes("href") = "#"
                            commandButton.Attributes("onclick") = [String].Format("return ShowNoteForm('{0}','{1}','{2}');", _CurrentDRAMemberID, 0, pagePath)
                            If Not IsInRole("Administrators") And Not IsInRole("Managers") And Not IsInRole("Processing") And Not IsInRole("Quality Control") Then
                                commandButton.Visible = False
                            End If
                        End If
                    End If
                    'btnNewAddress
                    commandButton = DirectCast(e.Item.FindControl("btnNewAddress"), Button)
                    If Not commandButton Is Nothing AndAlso commandButton.ID = "btnNewAddress" Then
                        If _CurrentDRAMemberID > 0 Then

                            Dim pagePath As String = Me.ResolveUrl("EditAddress.aspx")
                            commandButton.Attributes("href") = "#"
                            commandButton.Attributes("onclick") = [String].Format("return ShowAddressForm('{0}','{1}','{2}');", _CurrentDRAMemberID, 0, pagePath)
                            'If Not IsInRole("Administrators") And Not IsInRole("Managers") And Not IsInRole("Processing") Then
                            '    commandButton.Visible = False
                            'End If
                        End If
                    End If
                    'btnReport
                    commandButton = DirectCast(e.Item.FindControl("btnReport"), Button)
                    If Not commandButton Is Nothing AndAlso commandButton.ID = "btnReport" Then
                        If _CurrentDRAMemberID > 0 Then
                            Dim pagePath As String = Me.ResolveUrl("FullAnalysis.aspx")
                            commandButton.Attributes("href") = "#"
                            commandButton.Attributes("onclick") = [String].Format("return ShowReportForm('{0}','{1}');", _CurrentDRAMemberID, pagePath)
                            If Not IsInRole("Administrators") And Not IsInRole("Managers") And Not IsInRole("Processing") Then
                                commandButton.Visible = False
                            End If
                        End If
                    End If
                    'btnNewLoan
                    commandButton = DirectCast(e.Item.FindControl("btnNewLoan"), Button)
                    If Not commandButton Is Nothing AndAlso commandButton.ID = "btnNewLoan" Then
                        If _CurrentDRAMemberID > 0 Then
                            Dim pagePath As String = Me.ResolveUrl("EditLoan.aspx")
                            commandButton.Attributes("href") = "#"
                            commandButton.Attributes("onclick") = [String].Format("return ShowLoanForm('{0}','{1}','{2}');", _CurrentDRAMemberID, 0, pagePath)
                            If Not IsInRole("Administrators") And Not IsInRole("Managers") And Not IsInRole("Processing") Then
                                commandButton.Visible = False
                            End If
                        End If
                    End If
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqUsers_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqUsers.Selecting
            'Occurs before data-retrieval operation
            Try
                If IsInRole("Administrators") Or IsInRole("Managers") Or IsInRole("Receptionists") Then

                    If txtSearch.Text.Length = 0 Then

                        e.Result = From User In _db.Users _
                                   Join UserRole In _db.UserRoles _
                                     On UserRole.UserID Equals User.UserID _
                                   Join Role In _db.Roles _
                                     On UserRole.RoleID Equals Role.RoleID _
                                  Where Role.RoleName = "Members" _
                                    And (UserRole.ExpiryDate > DateTime.Today _
                                     Or UserRole.ExpiryDate Is Nothing) _
                                 Select User _
                                 Order By User.UserID Descending
                    Else
                        Select Case cbFieldName.SelectedValue
                            Case "LastName"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And User.LastName.ToLower.Contains(txtSearch.Text.ToLower) _
                                       Select User

                            Case "FirstName"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And User.LastName.ToLower.Contains(txtSearch.Text.ToLower) _
                                       Select User

                            Case "Email"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And User.LastName.ToLower.Contains(txtSearch.Text.ToLower) _
                                       Select User
                            Case "SSN"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Member.ssn = txtSearch.Text _
                                       Select User

                            Case "Phone"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And (Member.Phone = txtSearch.Text _
                                           Or Member.Cell = txtSearch.Text) _
                                       Select User

                            Case "PostalCode"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                         Join Address In _db.DRAMemberAddresses _
                                           On Member.DRAMemberID Equals Address.DRAMemberID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Address.PostalCode = txtSearch.Text _
                                       Select User

                            Case "MemberID"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Member.DRAMemberID = txtSearch.Text _
                                       Select User

                            Case "VerificationNo"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Member.VerificationNo.ToLower.Contains(txtSearch.Text.ToLower) _
                                       Select User
                        End Select
                    End If
                ElseIf Not IsInRole("Members") And IsInRole("Quality Control") Then
                    If txtSearch.Text.Length = 0 Then

                        e.Result = From User In _db.Users _
                                   Join UserRole In _db.UserRoles _
                                     On UserRole.UserID Equals User.UserID _
                                   Join Role In _db.Roles _
                                     On UserRole.RoleID Equals Role.RoleID _
                                   Join member In _db.DRAMembers _
                                     On User.UserID Equals member.UserID _
                                  Where Role.RoleName = "Members" _
                                    And (UserRole.ExpiryDate > DateTime.Today _
                                     Or UserRole.ExpiryDate Is Nothing) _
                                    And member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                 Select User _
                                 Order By User.UserID Descending
                    Else
                        Select Case cbFieldName.SelectedValue
                            Case "LastName"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join member In _db.DRAMembers _
                                           On User.UserID Equals member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And User.LastName.ToLower.Contains(txtSearch.Text.ToLower) _
                                          And member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User

                            Case "FirstName"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join member In _db.DRAMembers _
                                           On User.UserID Equals member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And User.LastName.ToLower.Contains(txtSearch.Text.ToLower) _
                                          And member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User

                            Case "Email"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join member In _db.DRAMembers _
                                           On User.UserID Equals member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And User.LastName.ToLower.Contains(txtSearch.Text.ToLower) _
                                          And member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User
                            Case "SSN"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Member.ssn = txtSearch.Text _
                                          And Member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User

                            Case "Phone"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And (Member.Phone = txtSearch.Text _
                                           Or Member.Cell = txtSearch.Text) _
                                          And Member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User

                            Case "PostalCode"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                         Join Address In _db.DRAMemberAddresses _
                                           On Member.DRAMemberID Equals Address.DRAMemberID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Address.PostalCode = txtSearch.Text _
                                          And Member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User

                            Case "MemberID"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Member.DRAMemberID = txtSearch.Text _
                                          And Member.QualityControl = Entities.Users.UserController.GetCurrentUserInfo().UserID _
                                       Select User

                            Case "VerificationNo"
                                e.Result = From User In _db.Users _
                                         Join UserRole In _db.UserRoles _
                                           On UserRole.UserID Equals User.UserID _
                                         Join Role In _db.Roles _
                                           On UserRole.RoleID Equals Role.RoleID _
                                         Join Member In _db.DRAMembers _
                                           On User.UserID Equals Member.UserID _
                                        Where Role.RoleName = "Members" _
                                          And (UserRole.ExpiryDate > DateTime.Today _
                                           Or UserRole.ExpiryDate Is Nothing) _
                                          And Member.VerificationNo.ToLower.Contains(txtSearch.Text.ToLower) _
                                       Select User
                        End Select
                    End If
                Else
                    e.Result = From User In _db.Users _
                               Join UserRole In _db.UserRoles _
                                 On UserRole.UserID Equals User.UserID _
                               Join Role In _db.Roles _
                                 On UserRole.RoleID Equals Role.RoleID _
                               Join Member In _db.DRAMembers _
                                 On User.UserID Equals Member.UserID _
                              Where Role.RoleName = "Members" _
                              Select User _
                               Order By User.UserID Descending
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDraMemberLoans_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs) Handles LinqDRAMemberLoans.Deleting
            Try
                Dim loan As DRAMemberLoan = CType(e.OriginalObject, DRAMemberLoan)

                _db.AddDRAMemberActivity(loan.DRAMemberID, 8, Entities.Users.UserController.GetCurrentUserInfo().UserID)
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Private Sub RadGridDRAMembers_ItemCommand(ByVal [source] As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridDRAMembers.ItemCommand
            Try
                If e.CommandName = RadGrid.ExpandCollapseCommandName Then
                    Dim item As GridItem
                    For Each item In e.Item.OwnerTableView.Items
                        If item.Expanded AndAlso Not item Is e.Item Then
                            item.Expanded = False
                        End If
                    Next item
                End If

                If (e.Item.OwnerTableView.Name = "MemberTable") Then
                    _CurrentDRAMemberID = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("DRAMemberID"))
                    If e.CommandName = RadGrid.ExpandCollapseCommandName Then
                        _db.AddDRAMemberActivity(_CurrentDRAMemberID, 3, Entities.Users.UserController.GetCurrentUserInfo().UserID)
                    End If
                End If

                If (e.Item.OwnerTableView.Name = "UserTable") Then
                    _CurrentUserID = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID"))
                    If e.CommandName = RadGrid.ExpandCollapseCommandName Then
                        _CurrentDRAMemberID = (From Member In _db.DRAMembers _
                                                   Where Member.UserID = _CurrentUserID _
                                                   Select Member.DRAMemberID).Single
                        _db.AddDRAMemberActivity(_CurrentDRAMemberID, 2, Entities.Users.UserController.GetCurrentUserInfo().UserID)
                    End If
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMembers_Inserting(ByVal sender As Object, ByVal e As LinqDataSourceInsertEventArgs) Handles LinqDRAMembers.Inserting
            'occurs before an insert operation
            Try
                If _CurrentUserID > 0 Then
                    Dim myDRAMember As DRAMember = CType(e.NewObject, DRAMember)

                    myDRAMember.UserID = _CurrentUserID
                    myDRAMember.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    myDRAMember.ModifiedDate = DateTime.Now
                    myDRAMember.CreatedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    myDRAMember.CreatedDate = DateTime.Now
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMemberAddresses_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs) Handles LinqDRAMemberAddresses.Deleting
            Try
                Dim address As DRAMemberAddress = CType(e.OriginalObject, DRAMemberAddress)

                _db.AddDRAMemberActivity(address.DRAMemberID, 9, Entities.Users.UserController.GetCurrentUserInfo().UserID)
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMemberAddresses_Inserting(ByVal sender As Object, ByVal e As LinqDataSourceInsertEventArgs) Handles LinqDRAMemberAddresses.Inserting
            'occurs before an insert operation
            Try
                If _CurrentDRAMemberID <> 0 Then
                    Dim address As DRAMemberAddress = CType(e.NewObject, DRAMemberAddress)

                    address.DRAMemberID = _CurrentDRAMemberID
                    address.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    address.ModifiedDate = DateTime.Now
                    address.CreatedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    address.CreatedDate = DateTime.Now
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMemberLoans_Inserting(ByVal sender As Object, ByVal e As LinqDataSourceInsertEventArgs) Handles LinqDRAMemberLoans.Inserting
            'occurs before an insert operation
            Try
                If _CurrentDRAMemberID <> 0 Then
                    Dim loan As DRAMemberLoan = CType(e.NewObject, DRAMemberLoan)

                    loan.DRAMemberID = _CurrentDRAMemberID
                    loan.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    loan.ModifiedDate = DateTime.Now
                    loan.CreatedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    loan.CreatedDate = DateTime.Now
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMemberNotes_Inserting(ByVal sender As Object, ByVal e As LinqDataSourceInsertEventArgs) Handles LinqDRAMemberNotes.Inserting
            'occurs before an insert operation
            Try
                If _CurrentDRAMemberID <> 0 Then
                    Dim note As DRAMemberNote = CType(e.NewObject, DRAMemberNote)

                    note.DRAMemberID = _CurrentDRAMemberID
                    note.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    note.ModifiedDate = DateTime.Now
                    note.CreatedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                    note.CreatedDate = DateTime.Now
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMembers_Updating(ByVal sender As Object, ByVal e As LinqDataSourceUpdateEventArgs) Handles LinqDRAMembers.Updating
            'Occurs before update operation
            Try
                Dim myDRAMember As DRAMember = CType(e.NewObject, DRAMember)

                myDRAMember.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                myDRAMember.ModifiedDate = DateTime.Now
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMemberAddresses_Updating(ByVal sender As Object, ByVal e As LinqDataSourceUpdateEventArgs) Handles LinqDRAMemberAddresses.Updating
            'Occurs before update operation
            Try
                Dim address As DRAMemberAddress = CType(e.NewObject, DRAMemberAddress)

                address.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                address.ModifiedDate = DateTime.Now
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqDRAMemberLoans_Updating(ByVal sender As Object, ByVal e As LinqDataSourceUpdateEventArgs) Handles LinqDRAMemberLoans.Updating
            'Occurs before update operation
            Try
                Dim loan As DRAMemberLoan = CType(e.NewObject, DRAMemberLoan)

                loan.ModifiedBy = Entities.Users.UserController.GetCurrentUserInfo().UserID
                loan.ModifiedDate = DateTime.Now
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub
        Private Sub SetGridPermissions()
            Try
                If IsInRole("Administrators") Then
                    'Turn on all capabilities

                    'Individual columns Member info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).Columns
                        If (column.UniqueName = "CreatedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "CreatedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "EditDRAMember") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next

                    'Individual columns Member addresses
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(0).Columns
                        If (column.UniqueName = "CreatedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "CreatedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "DeleteAddress") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next

                    'Individual columns Member loan info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "CreatedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "CreatedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "DeleteLoan") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next
                    'Individual columns Member note info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(2).Columns
                        If (column.UniqueName = "ModifiedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "TemplateEditNoteColumn") Then
                            CType(column, GridTemplateColumn).Visible = True
                        End If
                    Next
                ElseIf (IsInRole("Members") AndAlso Not IsInRole("Administrators")) Then
                    'Individual columns Member info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).Columns
                        If (column.UniqueName = "Status") Then
                            CType(column, GridDropDownColumn).ReadOnly = True
                        End If
                    Next

                    'Individual columns Member addresses
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(0).Columns
                        If (column.UniqueName = "DeleteAddress") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next

                    'Individual columns Member loan info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "DeleteLoan") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next
                ElseIf IsInRole("Managers") Then 'without Administrator
                    'Individual columns Member addresses
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(0).Columns
                        If (column.UniqueName = "DeleteAddress") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next

                    'Individual columns Member loan info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "DeleteLoan") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next
                    'Individual columns Member note info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(2).Columns
                        If (column.UniqueName = "ModifiedBy") Then
                            CType(column, GridDropDownColumn).Visible = True
                        End If
                        If (column.UniqueName = "ModifiedDate") Then
                            CType(column, GridBoundColumn).Visible = True
                        End If
                        If (column.UniqueName = "TemplateEditNoteColumn") Then
                            CType(column, GridTemplateColumn).Visible = True
                        End If
                    Next
                ElseIf IsInRole("Processing") Then
                    'Individual columns Member loan info

                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "AcctNo") Then
                            CType(column, GridBoundColumn).Visible = False
                        End If
                        If (column.UniqueName = "Creditor") Then
                            CType(column, GridBoundColumn).Visible = False
                        End If
                        If (column.UniqueName = "DebtType") Then
                            CType(column, GridDropDownColumn).Visible = False
                        End If
                    Next
                ElseIf IsInRole("Quality Control") Then
                    'Individual columns Member loan info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "AcctNo") Then
                            CType(column, GridBoundColumn).Visible = False
                        End If
                        If (column.UniqueName = "Creditor") Then
                            CType(column, GridBoundColumn).Visible = False
                        End If
                        If (column.UniqueName = "DebtType") Then
                            CType(column, GridDropDownColumn).Visible = False
                        End If
                    Next
                ElseIf IsInRole("Receptionists") Then
                    'Individual columns Member loan info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "AcctNo") Then
                            CType(column, GridBoundColumn).Visible = False
                        End If
                        If (column.UniqueName = "Creditor") Then
                            CType(column, GridBoundColumn).Visible = False
                        End If
                        If (column.UniqueName = "DebtType") Then
                            CType(column, GridDropDownColumn).Visible = False
                        End If
                    Next
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.Columns
                        If (column.UniqueName = "TemplateEditUserColumn") Then
                            CType(column, GridTemplateColumn).Visible = False
                        End If
                    Next
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).Columns
                        If (column.UniqueName = "TemplateEditMemberColumn") Then
                            CType(column, GridTemplateColumn).Visible = False
                        End If
                    Next
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "TemplateEditLoanColumn") Then
                            CType(column, GridTemplateColumn).Visible = False
                        End If
                    Next
                ElseIf IsInRole("Consultants") Then
                    'Individual columns Member addresses
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(0).Columns
                        If (column.UniqueName = "DeleteAddress") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next

                    'Individual columns Member loan info
                    For Each column As GridColumn In RadGridDRAMembers.MasterTableView.DetailTables(0).DetailTables(1).Columns
                        If (column.UniqueName = "DeleteLoan") Then
                            CType(column, GridButtonColumn).Visible = True
                        End If
                    Next
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
            Try
                If e.Argument = "Rebind" Then
                    RadGridDRAMembers.MasterTableView.SortExpressions.Clear()
                    RadGridDRAMembers.MasterTableView.GroupByExpressions.Clear()
                    'RadGridDRAMembers.MasterTableView.CurrentPageIndex = 1
                    RadGridDRAMembers.Rebind()
                ElseIf e.Argument = "RebindAndNavigate" Then
                    RadGridDRAMembers.MasterTableView.SortExpressions.Clear()
                    RadGridDRAMembers.MasterTableView.GroupByExpressions.Clear()
                    'RadGridDRAMembers.MasterTableView.CurrentPageIndex = RadGridDRAMembers.MasterTableView.PageCount - 1
                    'RadGridDRAMembers.MasterTableView.CurrentPageIndex = 1
                    RadGridDRAMembers.Rebind()
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
            Try
                If txtSearch.Text.Trim.Length > 0 Then
                    RadGridDRAMembers.Rebind()
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub btnShowAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowAll.Click
            Try
                txtSearch.Text = Nothing
                RadGridDRAMembers.Rebind()
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub cbFieldName_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles cbFieldName.SelectedIndexChanged
            txtSearch.Text = Nothing

            Try
                Select Case cbFieldName.SelectedValue
                    Case "LastName"
                        txtSearch.EmptyMessage = "Type last name to find"
                        txtSearch.Mask = "aaaaaaaaaaaaaaaaaaaaaaaaa"
                    Case "FirstName"
                        txtSearch.EmptyMessage = "Type first name to find"
                        txtSearch.Mask = "aaaaaaaaaaaaaaaaaaaaaaaaa"
                    Case "Email"
                        txtSearch.EmptyMessage = "Type e-mail to find"
                        txtSearch.Mask = "aaaaaaaaaaaaaaaaaaaaaaaaa"
                    Case "SSN"
                        txtSearch.EmptyMessage = "Type ssn to find"
                        txtSearch.Mask = "###-##-####"
                    Case "Phone"
                        txtSearch.EmptyMessage = "Type phone to find"
                        txtSearch.Mask = "(###) ###-####"
                    Case "MemberID"
                        txtSearch.EmptyMessage = "Type member ID to find"
                        txtSearch.Mask = "#######################"
                    Case "PostalCode"
                        txtSearch.EmptyMessage = "Type postal code to find"
                        txtSearch.Mask = "aaaaaaaaaa"
                    Case "VerificationNo"
                        txtSearch.EmptyMessage = "Type Verification No to find"
                        txtSearch.Mask = "aaaaaaaaaaaaaaaaaaaaaaaaa"
                End Select
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqConsultants_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqConsultants.Selecting
            Try
                e.Result = From User In _db.Users _
                           Join UserRole In _db.UserRoles _
                             On UserRole.UserID Equals User.UserID _
                           Join Role In _db.Roles _
                             On UserRole.RoleID Equals Role.RoleID _
                          Where Role.RoleName = "Consultants" _
                         Select User.UserID, User.DisplayName
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqQualityControl_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqQualityControl.Selecting
            Try
                e.Result = From User In _db.Users _
                           Join UserRole In _db.UserRoles _
                             On UserRole.UserID Equals User.UserID _
                           Join Role In _db.Roles _
                             On UserRole.RoleID Equals Role.RoleID _
                          Where Role.RoleName = "Quality Control" _
                         Select User.UserID, User.DisplayName
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub LinqEmployees_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqEmployees.Selecting
            Try
                e.Result = From User In _db.Users _
                           Join UserRole In _db.UserRoles _
                             On UserRole.UserID Equals User.UserID _
                           Join Role In _db.Roles _
                             On UserRole.RoleID Equals Role.RoleID _
                          Where (Role.RoleName = "Quality Control" _
                             Or Role.RoleName = "Consultants" _
                             Or Role.RoleName = "Administrators" _
                             Or Role.RoleName = "Managers" _
                             Or Role.RoleName = "Receptionists" _
                             Or Role.RoleName = "Processing") _
                        Distinct Select User.UserID, User.DisplayName

            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try

        End Sub
    End Class
End Namespace

Thank you in advance!
0
Milan
Telerik team
answered on 17 Sep 2009, 03:21 AM
Hello Charles Trig,

You should save the expand state (SaveExpandedRows) just before an operation that collapses all rows and reexpand the rows (ExpandRows) right after that. For example, when inserting new item save the expanded rows, add an item to your LinqDataSource, and right after that expand all rows.

Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ori Tidhar
Top achievements
Rank 1
answered on 05 Nov 2009, 08:59 AM
Hi,

The given (SaveExpandedRows / ExpandRows) code no longer works.

I tried solving it using:
var oRows = this.RadGridView1.ChildrenOfType<GridViewExpandableRow>().Where(
                                r => r.ParentGrid == this.RadGridView1).ToList();

however if I run the above line right after Rebind(), zero results are returned.

Can you please assist with this ?
0
Milan
Telerik team
answered on 05 Nov 2009, 01:09 PM
Hi Ori Tidhar,

I just want to make sure which version of RadGridView you are using. Is it 2009_2_0911?


Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ori Tidhar
Top achievements
Rank 1
answered on 05 Nov 2009, 02:00 PM

One of your builds:

2009.2.911.35

Thanks

0
Milan
Telerik team
answered on 06 Nov 2009, 09:37 AM
Hi Ori Tidhar,

The version that you are using should automatically keep all expanded rows expanded after Rebind or change in the source collection - the use of the expand/collapse methods should be redundant.

In case the expand state of rows is not preserved we would need more information about your scenario to be able to provide a working solution.


All the best,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ori Tidhar
Top achievements
Rank 1
answered on 11 Nov 2009, 02:13 PM

Hello,

It does preserve, however I am using a parent-child grid with a datatrigger (and a convereter) on the child cells foreground.
Because the datatrigger does not change when its underling datarowview changes, I do a Rebind.

When I do a Rebind

and in the same method run a

"var expnderRows = rgv.ChildrenOfType<GridViewRow>().ToList();"

it returns ONLY one row (the GridViewNewRow), although there are more rows in the grid.

Can I cause the trigger to work without doing a rebind, or better yet, how
can I access the grid's rows right after a rebind ?

Thanks

<telerik:GridViewDataColumn UniqueName="col_ActName1"
                                                CellStyle="{StaticResource SubActivity}"
                                                DataMemberBinding="{Binding Path=ActivityName}"
                                                IsVisible="True" Header="Activity Name"
                                                HeaderTextAlignment="Center" Width="90"
                                                TextAlignment="Left"
                                                DataType="{x:Type sys:String}">
                                    <telerik:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock
                                        Text="{Binding lcMarkError,
                                           Converter={StaticResource MyMarkErrorConverter}}" />
                                                <TextBlock
                                        Text="{Binding ActivityName}" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellTemplate>
                                </telerik:GridViewDataColumn>

0
Milan
Telerik team
answered on 11 Nov 2009, 03:31 PM
Hi Ori Tidhar,

When you call Rebind the grid will recreate its containers but that is done asynchroneously and that is why the rows are not available. If you try to get the rows using a Dispatcher you should be able to get the rows.

You could try the following:

this.gridView.Rebind();
this.Dispatcher.BeginInvoke(new Action(() => UpdateRows()),
        DispatcherPriority.ApplicationIdle, null);
  
private void UpdateRows()
{
    var rows = this.gridView.ChildrenOfType<GridViewRow>();
  
    // update rows
}


Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Atul Katiyar
Top achievements
Rank 1
Answers by
Milan
Telerik team
Charles Trig
Top achievements
Rank 1
Ori Tidhar
Top achievements
Rank 1
Share this question
or