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

RadGrid Exporting causes CommandItem to be Exported too

12 Answers 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 14 Jul 2014, 06:45 PM
I am attempting to export from a RadGrid and instead of getting a nice exported graph, I get a graph that has the Command Item bar attached to it. IT has the 4 export buttons as well. It posts all the buttons and has mouseover text on the sortable columns saying, 'click to sort'. It also prints out the hyper links and attempts to display the images from the webpage. It then also prints the boxes for the filtering and the text that would be included were you to filter this graph beforehand.

The weird thing is that I have two RadGrids on this same page and one works perfectly while this one doesn't.

For reference, the image of the broken one can be seen on imgur here: http://i.imgur.com/KKtITTX.png

I have attempted the following things:

Protected Sub rgvSection_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs)
            If e.CommandName = RadGrid.ExportToWordCommandName Then
                For Each item As GridCommandItem In e.Item.OwnerTableView.GetItems(GridItemType.CommandItem)
                    item.Visible = False
                Next
            End If
End Sub

This had no change whatsoever.

Attempted:

<ExportSettings ExportOnlyData="true"></ExportSettings>

Also had no effect. I swear that I have done multiple graphs on the same page exporting just fine. Not really sure what I'm running into here. Any feedback is well appreciated!

12 Answers, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 14 Jul 2014, 07:00 PM
I was able to get rid of the CommandItem with the 4 buttons, although the rest of it is still there.

e.Item.OwnerTableView.CommandItemDisplay = False



0
Alexander
Top achievements
Rank 1
answered on 14 Jul 2014, 07:05 PM
I was able to get rid of the filter boxes with this:

Protected Sub rgvSection_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles rgvNoSection.ItemCreated
            If e.Item.ItemType = GridItemType.FilteringItem Then
                e.Item.Visible = False
            End If
        End Sub
0
Alexander
Top achievements
Rank 1
answered on 14 Jul 2014, 07:12 PM
[quote]Alexander said:I was able to get rid of the filter boxes with this:

Protected Sub rgvSection_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles rgvNoSection.ItemCreated
            If e.Item.ItemType = GridItemType.FilteringItem Then
                e.Item.Visible = False
            End If
        End Sub
[/quote]

And I didn't realize this took it away beforehand, so I have to remove this.
0
Alexander
Top achievements
Rank 1
answered on 17 Jul 2014, 02:59 PM
So, I am still experiencing this issue. Unfortunately it is still not working. I even went as far as deleting the second graph and remaking it. Still the same issue. Then I just copied the other grid and pasted it over my old one, changed the ID and still the problem persists. Not really sure where to go from here.
0
Shinu
Top achievements
Rank 2
answered on 18 Jul 2014, 08:27 AM
Hi Alexander,

I am not sure about your requirement. Can u please elaborate your requirement for further help.

Thanks,
Shinu.
0
Alexander
Top achievements
Rank 1
answered on 18 Jul 2014, 09:05 PM
Yeah Shinu, thanks for replying!

I have two Radgrids on the same page. The export works for one while it doesn't work correctly for the other. I'm not really certain as to why it isn't working correctly. I posted the image of the broken one in my first post. It shouldn't show the CommandItems, the filter, the hovertext, or hyperlinks. To try and fix it, I went as far as copying the correctly made one and pasting it over the broken one. I changed the ID associated with it and that was it. Nothing else was different, but it still doesn't work correctly.

So either there is something wrong within my load or I don't really know what. The Excel/PDF/CSV/Word exports only seem work while one Radgrid is on the page.

What I am trying to figure out is if there is a way to programmatically remove all the command items, hover text, filter boxes, and hyperlinks.

Again, thanks for replying earlier Shinu!
0
Kostadin
Telerik team
answered on 23 Jul 2014, 08:58 AM
Hi Alexander,

Generally the controls which is exported to Excel (such as filter TextBox and export Buttons) will be removed when you enable ExportOnlyData property. I noticed that you are applying this property to the grid and you still experience the same issue. Since I am unable to replicate the issue could you please provide your code declaration and the related code behind in order to investigate it further?

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexander
Top achievements
Rank 1
answered on 24 Jul 2014, 09:27 PM
I actually have this problem appearing in two locations now. This is the first occurence. Instead of downloading a messed up grid, it just refreshes and does nothing.

<
table width="100%">
    <tr id="LocList" runat="server">
        <td style="white-space: nowrap" >
           
        </td>
        <td align="right" ><GraphBtn:WinampButton ID="gbPrintMasterList" runat="server" TemplateName="Print" Text="Print Master List" /></td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Label ID="Label3" runat="server" Text="View: " CssClass="SubHead"></asp:Label>
            <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
                RepeatLayout="Flow" AutoPostBack="True">
                <asp:ListItem Selected="True" Value="0">Categories</asp:ListItem>
                <asp:ListItem Value="1">Complete List</asp:ListItem>
            </asp:RadioButtonList>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Label ID="Label2" runat="server" Text="Search: " CssClass="SubHead"></asp:Label
            <asp:DropDownList ID="ddlSearchType" runat="server">
                <asp:ListItem Value="0">Title</asp:ListItem>
                <asp:ListItem Value="1">Document Number</asp:ListItem>
            </asp:DropDownList>
             <asp:textbox ID="tbSearchTerm" runat="server"></asp:textbox>
            <GraphBtn:WinampButton ID="runsearch" runat="server" TemplateName="View" Text="Search" />
                <GraphBtn:WinampButton ID="clearsearch" runat="server" TemplateName="Base" Text="Clear Search" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Repeater ID="repSections" runat="server" EnableViewState="False">
                <ItemTemplate>
                   <div class="ACCalert" style="color: #FFFFFF;">
                        <dnn:SectionHead ID="dshModule" runat="server" Section="tblSection" ResourceKey="ModuleSettings"
                            PersonailzationKey='<%#DataBinder.Eval(Container.DataItem, "ID")%>' 
                            PersonalizationName = "QMSGlobalViewSection" IncludeRule="false" MaxImageUrl="~/images/expand.jpg" IsExpanded="false" MinImageUrl="~/images/collapse.jpg" />
                    </div>
                    <table width="100%" cellpadding="0" cellspacing="0" id="tblSection" runat="server">
                        <tr>
                            <td>
                                <telerik:radgrid runat="server" ID="rgvSection" GroupingSettings-CaseSensitive="false" AutoGenerateColumns="false" Width="100%" ActiveItemStyle-VerticalAlign="Top" AllowSorting="true"
                                    ActiveItemStyle-HorizontalAlign="Left" OnItemDataBound="rgvSection_ItemDataBound" OnNeedDataSource="rgvSection_NeedDataSource" OnItemCommand="rgvSection_ItemCommand">
                                    <MasterTableView AllowMultiColumnSorting="true" AllowFilteringByColumn="true" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false">
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="DocNumber" HeaderText="Doc Number" ShowFilterIcon="false" SortExpression="DocNumber" AutoPostBackOnFilter="true" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridTemplateColumn DataField="PolicyName" UniqueName="PolicyName" HeaderText="Procedure Name and Files" ShowFilterIcon="false" SortExpression="PolicyName" AutoPostBackOnFilter="true" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblPolicyName" runat="server" Text=""></asp:Label>
                                                    <br />
                                                    <br />
                                                    <asp:fileUpload ID="FileLinkControl1" runat="server"
                                                        ShowDelete="false" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn AutoPostBackOnFilter="true" DataField="DisplayName" UniqueName="DisplayName" HeaderText="Doc Owner / Last Update" ShowFilterIcon="false" SortExpression="DisplayName,DateEntered" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblDocOwner" runat="server" Text=""></asp:Label>
                                                    <br />
                                                    <asp:Label ID="lblUpdate" runat="server" Text=""></asp:Label>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn AllowFiltering="false" ShowFilterIcon="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibPrintPolicy" runat="server" TemplateName="View" ShowFilterIcon="false" Text="View & Print" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </MasterTableView>
                                </telerik:radgrid>
                            </td>
                        </tr>
                        <tr>
                            <td style="background-color: #5D7B9D; font-weight: bold; color: White; font-size: large;">
                                <hr />
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:Repeater>
            <telerik:radgrid runat="server" ID="rgvNoSection" GroupingSettings-CaseSensitive="false" AutoGenerateColumns="false" Width="100%" ActiveItemStyle-VerticalAlign="Top" AllowSorting="true"
                                    ActiveItemStyle-HorizontalAlign="Left" OnItemDataBound="rgvSection_ItemDataBound" OnNeedDataSource="rgvSection_NeedDataSource" OnItemCommand="rgvSection_ItemCommand">
                <MasterTableView AllowMultiColumnSorting="true" AllowFilteringByColumn="true" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false">
                    <Columns>
                        <telerik:GridBoundColumn DataField="DocNumber" HeaderText="Doc Number" ShowFilterIcon="false" SortExpression="DocNumber" AutoPostBackOnFilter="true" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn DataField="PolicyName" UniqueName="PolicyName" HeaderText="Procedure Name and Files" ShowFilterIcon="false" SortExpression="PolicyName" AutoPostBackOnFilter="true" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <asp:Label ID="lblPolicyName" runat="server" Text=""></asp:Label>
                                <br />
                                <br />
                                <asp:fileUpload ID="FileLinkControl1" runat="server"
                                    ShowDelete="false" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AutoPostBackOnFilter="true" DataField="DisplayName" UniqueName="DisplayName" HeaderText="Doc Owner / Last Update" ShowFilterIcon="false" SortExpression="DisplayName,DateEntered" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <asp:Label ID="lblDocOwner" runat="server" Text=""></asp:Label>
                                <br />
                                <asp:Label ID="lblUpdate" runat="server" Text=""></asp:Label>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AllowFiltering="false" ShowFilterIcon="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <GraphBtn:WinampButton ID="ibPrintPolicy" runat="server" TemplateName="View" ShowFilterIcon="false" Text="View & Print" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:radgrid>
            <br />
        </td>
    </tr>
</table>


#Region "Private Members"
 
        Private LocationID As Integer = Null.NullInteger
        Private CorpID As Integer = Null.NullInteger
        Private RoleInteger As Integer = Null.NullInteger
        Private myData As New RCIData
        Private SearchType As Integer = Null.NullInteger
 
#End Region
 
#Region "Private Methods"
 
        Private Sub BindPolicyList()
            ' bind the content to the repeater
            Me.repSections.DataSource = myData.ProcTable("GetSectionsByOwner", "@OwnerID", 28139, "@QMS", 1)
            Me.repSections.DataBind()
        End Sub
 
        Private Sub BindPolicyListAlternateList()
            Dim aDataTable As New DataTable
 
            Select Case SearchType
                Case 0 'search toitle
                    aDataTable = myData.ProcTable("GetPoliciesByLocation_SearchTitle", "@LocationID", 43531, "@QMS", 1, "@titlestring", Me.tbSearchTerm.Text, "@OwnerID", 28139)
                Case 1 ' search doc number
                    aDataTable = myData.ProcTable("GetPoliciesByLocation_SearchDocNumber", "@LocationID", 43531, "@QMS", 1, "@DocNumber", Me.tbSearchTerm.Text, "@OwnerID", 28139)
                Case Else
                    aDataTable = myData.ProcTable("GetPoliciesByLocation", "@LocationID", 43531, "@QMS", 1, "@OwnerID", 28139)
            End Select
 
            Me.rgvNoSection.DataSource = aDataTable
            Me.rgvNoSection.DataBind()
 
        End Sub
 
#End Region
 
#Region "Page Methods"
 
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                'If Not Page.IsPostBack Then
                Select Case Me.RadioButtonList1.SelectedValue
                    Case "0"
                        BindPolicyList() 'this has categories
                    Case "1"
                        BindPolicyListAlternateList() 'no categories
                End Select
                'End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub
 
#End Region
 
#Region "Event Handlers"
 
        Protected Sub repSections_ItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles repSections.ItemCreated
            Dim myRGVDataList As New RadGrid
 
            myRGVDataList = CType(e.Item.FindControl("rgvSection"), RadGrid)
 
            AddHandler myRGVDataList.NeedDataSource, AddressOf rgvSection_NeedDataSource
            AddHandler myRGVDataList.ItemDataBound, AddressOf rgvSection_ItemDataBound
            AddHandler myRGVDataList.ItemCommand, AddressOf rgvSection_ItemCommand
        End Sub
 
        Protected Sub repSections_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repSections.ItemDataBound
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                Dim myLabel As New Modules.SectionHeadControl ' DotNetNuke.UI.UserControls.SectionHeadControl
                myLabel = CType(e.Item.FindControl("dshModule"), Modules.SectionHeadControl) ' DotNetNuke.UI.UserControls.SectionHeadControl)
                myLabel.Text = "<font color=white>" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "SectionName")) & "</font>"
 
                Dim myDataList As New GridView
                Dim myRGVDataList As New RadGrid
                myRGVDataList = CType(e.Item.FindControl("rgvSection"), RadGrid)
                Dim aDataTable As New DataTable
 
                Select Case SearchType
                    Case 0 'search title
                        aDataTable = myData.ProcTable("GetPoliciesBySectionByLocation_SearchTitle", _
                            "@LocationID", 43531, _
                            "@SectionID", Convert.ToInt32(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")), _
                            "@QMS", 1, "@titlestring", Me.tbSearchTerm.Text)
                    Case 1 ' search doc number
                        aDataTable = myData.ProcTable("GetPoliciesBySectionByLocation_SearchDocNumber", _
                            "@LocationID", 43531, _
                            "@SectionID", Convert.ToInt32(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")), _
                            "@QMS", 1, "@DocNumber", Me.tbSearchTerm.Text)
                    Case Else
                        aDataTable = myData.ProcTable("GetPoliciesBySectionByLocation", _
                            "@LocationID", 43531, _
                            "@SectionID", Convert.ToInt32(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")), _
                            "@QMS", 1)
                End Select
 
                myRGVDataList.DataSource = aDataTable
                myRGVDataList.DataBind()
            End If
        End Sub
 
        Protected Sub rgvSection_NeedDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs)
 
        End Sub
 
        Protected Sub rgvSection_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
            If TypeOf e.Item Is GridDataItem Then
                'litPolicy
                Dim myLiteral As New Label
                myLiteral = CType(e.Item.FindControl("lblPolicyName"), Label)
 
                Dim myLabel As String = Null.NullString
                myLabel = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "PolicyName"))
                If myLiteral IsNot Nothing Then
                    myLiteral.Text = "<a name=""" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")) & """></a>" & myLabel
                End If
 
                myLiteral = New Label
                myLiteral = CType(e.Item.FindControl("lblDocOwner"), Label)
                If myLiteral IsNot Nothing Then
                    myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DisplayName"))
                End If
 
                myLiteral = New Label
                myLiteral = CType(e.Item.FindControl("lblUpdate"), Label)
                If myLiteral IsNot Nothing Then
                    myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DateEntered"))
                End If
 
                'need to find and load file link control here
                Dim myFiles As FileUpload = CType(e.Item.FindControl("FileLinkControl1"), FileUpload)
                If myFiles IsNot Nothing Then
                    myFiles.DataSource = myData.TextTable("SELECT a.* FROM PolicyManual_Files a WITH (NOLOCK) INNER JOIN NewestPolicy_Version b WITH (NOLOCK) ON a.VersionID = b.ID WHERE b.PolicyID = @PolicyID", "@PolicyID", System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID"))
                End If
 
                If myFiles.DataSource.Rows.Count < 1 Then
                    myFiles.Visible = False
                End If
 
                Dim myPrintLink As New WinampButton
                myPrintLink = CType(e.Item.FindControl("ibPrintPolicy"), WinampButton)
                If myPrintLink IsNot Nothing Then
                    myPrintLink.CausesPostback = False
                    myPrintLink.OnClientClick = "document.location.href='" & EditUrl("policy", Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")), "Print", "ExcludeViewStateCache=True") & "';"
                End If
            End If
        End Sub
 
        Protected Sub rgvSection_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs)
 
        End Sub
 
        Protected Sub clearsearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles clearsearch.Click
            SearchType = Null.NullInteger
            Me.tbSearchTerm.Text = Null.NullString
            Select Case Me.RadioButtonList1.SelectedValue
                Case "0"
                    Me.repSections.Visible = True
                    Me.rgvNoSection.Visible = False
                    BindPolicyList()
                Case "1"
                    Me.repSections.Visible = False
                    Me.rgvNoSection.Visible = True
                    BindPolicyListAlternateList()
            End Select
        End Sub
 
        Protected Sub runsearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles runsearch.Click
            SearchType = Me.ddlSearchType.SelectedValue
            Select Case Me.RadioButtonList1.SelectedValue
                Case "0"
                    Me.repSections.Visible = True
                    Me.rgvNoSection.Visible = False
                    BindPolicyList()
                Case "1"
                    Me.repSections.Visible = False
                    Me.rgvNoSection.Visible = True
                    BindPolicyListAlternateList()
            End Select
        End Sub
 
        Protected Sub gbPrintMasterList_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles gbPrintMasterList.Click
            Dim ExtraString As String = Null.NullString
            If Me.tbSearchTerm.Text.Length > 0 Then
                Response.Redirect(EditUrl("Location", "43531", "MasterPrint", "sType=" & Me.ddlSearchType.SelectedValue.ToString, "Terms=" & Me.tbSearchTerm.Text.ToString, "ExcludeViewStateCache=True"), True)
            Else
                Response.Redirect(EditUrl("Location", "43531", "MasterPrint", "ExcludeViewStateCache=True"), True)
            End If
        End Sub
 
        Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
            Select Case Me.RadioButtonList1.SelectedValue
                Case "0"
                    Me.repSections.Visible = True
                    Me.rgvNoSection.Visible = False
                    BindPolicyList()
                Case "1"
                    Me.repSections.Visible = False
                    Me.rgvNoSection.Visible = True
                    BindPolicyListAlternateList()
            End Select
        End Sub
 
#End Region
 
    End Class
 
End Namespace
 
The post below this one will show the code behind/in front corresponding to the problem at hand.
0
Alexander
Top achievements
Rank 1
answered on 24 Jul 2014, 09:34 PM
<script type="text/javascript">
    function pageLoad() {
        standardistaTableSortingInit();
    }
</script>
 
<table width="100%">
    <tr id="LocList" runat="server">
        <td style="white-space: nowrap">
            <asp:Label ID="lblLocList" runat="server" Text="Locations Avaliable: " />
            <uc1:LocationChooser ID="lcLocation" runat="server" AutoPostBack="true" DisplayLevels="Location"
                ShowAll="false" />
        </td>
        <td align="right">
            <GraphBtn:WinampButton ID="btnExportMasterList" runat="server" TemplateName="Save"
                Text="Export Master List" />
            <GraphBtn:WinampButton ID="gbPrintMasterList" runat="server" TemplateName="Print"
                Text="Print Master List" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Label ID="lblProcedureTypes" runat="server" Text="Procedure Type: " CssClass="SubHead" />
            <asp:RadioButtonList ID="rblProcedures" runat="server" RepeatDirection="Horizontal"
                RepeatLayout="Flow" AutoPostBack="True">
                <asp:ListItem Selected="True" Value="0">Corporate Procedures</asp:ListItem>
                <asp:ListItem Value="1">Facility Procedures</asp:ListItem>
            </asp:RadioButtonList>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Label ID="Label3" runat="server" Text="View: " CssClass="SubHead" />
            <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
                RepeatLayout="Flow" AutoPostBack="True">
                <asp:ListItem Selected="True" Value="0">Categories</asp:ListItem>
                <asp:ListItem Value="1">Complete List</asp:ListItem>
            </asp:RadioButtonList>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label2" runat="server" Text="Search: " CssClass="SubHead" /> 
            <asp:DropDownList ID="ddlSearchType" runat="server">
                <asp:ListItem Value="0">Title</asp:ListItem>
                <asp:ListItem Value="1">Document Number</asp:ListItem>
            </asp:DropDownList>
             <asp:textbox ID="tbSearchTerm" runat="server" />
            <GraphBtn:WinampButton ID="runsearch" runat="server" TemplateName="View" Text="Search" />
            <GraphBtn:WinampButton ID="clearsearch" runat="server" TemplateName="Base" Text="Clear Search" />
        </td>
        <td align="right">
            <asp:CheckBox ID="cbExpandAll" runat="server" AutoPostBack="True" Text="Expand All Sections"
                TextAlign="Left" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Repeater ID="repSections" runat="server" EnableViewState="False">
                <ItemTemplate>
                    <div class="ACCalert" style="color: #FFFFFF; background: #387C2B;">
                        <dnn:SectionHead ID="dshModule" runat="server" Section="tblSection" ResourceKey="ModuleSettings"
                            PersonailzationKey='<%#DataBinder.Eval(Container.DataItem, "ID")%>' PersonalizationName="MasterDocumentListViewSection"
                            IncludeRule="false" MaxImageUrl="~/images/expand.jpg" MinImageUrl="~/images/collapse.jpg" />
                    </div>
                    <table width="100%" cellpadding="0" cellspacing="0" id="tblSection" runat="server">
                        <tr>
                            <td>
                                <radgrid runat="server" ID="rgvSection" GroupingSettings-CaseSensitive="false" AutoGenerateColumns="false" Width="100%" ActiveItemStyle-VerticalAlign="Top" AllowSorting="true"
                                    ActiveItemStyle-HorizontalAlign="Left" OnItemDataBound="rgvSection_ItemDataBound" OnNeedDataSource="rgvSection_NeedDataSource" OnItemCommand="rgvSection_ItemCommand" ExportSettings-ExportOnlyData="true">
                                    <MasterTableView AllowMultiColumnSorting="true" AllowFilteringByColumn="true" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false">
                                        <Columns>
                                            <telerik:GridTemplateColumn DataField="DocNumber" HeaderText="Doc Number" ShowFilterIcon="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" SortExpression="DocNumber"
                                                AutoPostBackOnFilter="true">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblDocNumber2" runat="server" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn DataField="PolicyName" HeaderText="Procedure Name and Files" ShowFilterIcon="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left"
                                                AutoPostBackOnFilter="true" SortExpression="PolicyName">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblPolicyName2" runat="server" Text="" />
                                                    <br />
                                                    <br />
                                                    <asp:FileUpload ID="FileLinkControl12" runat="server"
                                                        ShowDelete="false" ShowRotate="false" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn DataField="DisplayName" HeaderText="Corp Owner / Last Update" ShowFilterIcon="false" AutoPostBackOnFilter="true" SortExpression="DisplayName" ItemStyle-VerticalAlign="Top"
                                                 ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblDocOwner2" runat="server" Text="" />
                                                    <br />
                                                    <asp:Label ID="lblUpdate2" runat="server" Text="" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn HeaderText="Local Reviewer / Last Review Date" HeaderStyle-ForeColor="White" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" Visible="false">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="btnAssignLocationOwners2" runat="server" TemplateName="GoNext"
                                                        Text="Assign Owners" Visible="false" />
                                                    <asp:HyperLink ID="hypAssignLocationOwners2" runat="server" NavigateUrl="" Text=""
                                                        Visible="false" />
                                                    <asp:Label ID="lblAssignLocationOwners2" runat="server" CssClass="RCI_MainLabel" Text=""
                                                        Visible="false" /><br />
                                                    <GraphBtn:WinampButton ID="btnReview2" runat="server" TemplateName="GoNext" Text="Review"
                                                        Visible="false" />
                                                    <asp:HyperLink ID="hypReview2" runat="server" NavigateUrl="" Text="" Visible="false" />
                                                    <asp:Label ID="lblReview2" runat="server" Text="" Visible="false" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn Exportable="false" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibPrintPolicy2" runat="server" TemplateName="View" Text="View & Print" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn Exportable="false" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibEdit2" runat="server" TemplateName="Edit" Text="Edit Info" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn Exportable="false" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibAudit2" runat="server" TemplateName="View" Text="Audit" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </MasterTableView>
                                </radgrid>
                            </td>
                        </tr>
                        <tr>
                            <td style="background-color: #387C2B; font-weight: bold; color: White; font-size: large;">
                                <hr />
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:Repeater>
            <radgrid runat="server" ID="rgvNoSection" GroupingSettings-CaseSensitive="false" AutoGenerateColumns="false" Width="100%" ActiveItemStyle-VerticalAlign="Top" AllowSorting="true"
                                    ActiveItemStyle-HorizontalAlign="Left" OnItemDataBound="rgvSection_ItemDataBound" OnNeedDataSource="rgvSection_NeedDataSource" OnItemCommand="rgvSection_ItemCommand" ExportSettings-ExportOnlyData="true">
                                    <MasterTableView AllowMultiColumnSorting="true" AllowFilteringByColumn="true" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false">
                                        <Columns>
                                            <telerik:GridTemplateColumn DataField="DocNumber" HeaderText="Doc Number" ShowFilterIcon="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" SortExpression="DocNumber"
                                                AutoPostBackOnFilter="true">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblDocNumber2" runat="server" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn DataField="PolicyName" HeaderText="Procedure Name and Files" ShowFilterIcon="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left"
                                                AutoPostBackOnFilter="true" SortExpression="PolicyName">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblPolicyName2" runat="server" Text="" />
                                                    <br />
                                                    <br />
                                                    <asp:FileUpload ID="FileLinkControl12" runat="server"
                                                        ShowDelete="false" ShowRotate="false" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn DataField="DisplayName" HeaderText="Corp Owner / Last Update" ShowFilterIcon="false" AutoPostBackOnFilter="true" SortExpression="DisplayName" ItemStyle-VerticalAlign="Top"
                                                 ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblDocOwner2" runat="server" Text="" />
                                                    <br />
                                                    <asp:Label ID="lblUpdate2" runat="server" Text="" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn HeaderText="Local Reviewer / Last Review Date" HeaderStyle-ForeColor="White" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" Visible="false">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="btnAssignLocationOwners2" runat="server" TemplateName="GoNext"
                                                        Text="Assign Owners" Visible="false" />
                                                    <asp:HyperLink ID="hypAssignLocationOwners2" runat="server" NavigateUrl="" Text=""
                                                        Visible="false" />
                                                    <asp:Label ID="lblAssignLocationOwners2" runat="server" CssClass="RCI_MainLabel" Text=""
                                                        Visible="false" /><br />
                                                    <GraphBtn:WinampButton ID="btnReview2" runat="server" TemplateName="GoNext" Text="Review"
                                                        Visible="false" />
                                                    <asp:HyperLink ID="hypReview2" runat="server" NavigateUrl="" Text="" Visible="false" />
                                                    <asp:Label ID="lblReview2" runat="server" Text="" Visible="false" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn Exportable="false" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibPrintPolicy2" runat="server" TemplateName="View" Text="View & Print" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn Exportable="false" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibEdit2" runat="server" TemplateName="Edit" Text="Edit Info" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn Exportable="false" AllowFiltering="false" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <GraphBtn:WinampButton ID="ibAudit2" runat="server" TemplateName="View" Text="Audit" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </MasterTableView>
                                </radgrid>
            <asp:GridView ID="gvNoSection" runat="server" AutoGenerateColumns="False"
                Width="100%" OnRowDataBound="gvSection_RowDataBound">
                <%--CssClass="RCIGrid sortable"--%>
                <Columns>
                    <asp:TemplateField HeaderText="Doc Number">
                        <HeaderStyle Font-Bold="True" ForeColor="White" HorizontalAlign="Left" Wrap="false" />
                        <ItemTemplate>
                            <asp:Label ID="lblDocNumber" runat="server" Text="" />
                        </ItemTemplate>
                        <ItemStyle VerticalAlign="Top" Wrap="false" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Procedure Name and Files">
                        <HeaderStyle Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
                        <ItemTemplate>
                            <asp:Label ID="lblPolicyName" runat="server" Text="" />
                            <br />
                            <br />
                            <asp:FileUpload ID="FileLinkControl1" runat="server"
                                ShowDelete="false" />
                        </ItemTemplate>
                        <ItemStyle Width="100%" VerticalAlign="Top" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Doc Owner / Last Update">
                        <HeaderStyle Font-Bold="True" ForeColor="White" HorizontalAlign="Left" Wrap="false" />
                        <ItemTemplate>
                            <asp:Label ID="lblDocOwner" runat="server" Text="" />
                            <br />
                            <asp:Label ID="lblUpdate" runat="server" Text="" />
                        </ItemTemplate>
                        <ItemStyle Width="100%" VerticalAlign="Top" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Local Reviewer / Last Review Date" Visible="false">
                        <ItemTemplate>
                            <GraphBtn:WinampButton ID="btnAssignLocationOwners" runat="server" TemplateName="GoNext"
                                Text="Assign Owners" Visible="false" />
                            <asp:HyperLink ID="hypAssignLocationOwners" runat="server" NavigateUrl="" Text=""
                                Visible="false" />
                            <asp:Label ID="lblAssignLocationOwners" runat="server" CssClass="RCI_MainLabel" Text=""
                                Visible="false" /><br />
                            <GraphBtn:WinampButton ID="btnReview" runat="server" TemplateName="GoNext" Text="Review"
                                Visible="false" />
                            <asp:HyperLink ID="hypReview" runat="server" NavigateUrl="" Text="" Visible="false" />
                            <asp:Label ID="lblReview" runat="server" Text="" Visible="false" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <HeaderStyle Font-Bold="True" ForeColor="White" HorizontalAlign="center" />
                        <ItemTemplate>
                            <GraphBtn:WinampButton ID="ibPrintPolicy" runat="server" TemplateName="View" Text="View & Print" />
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="center" VerticalAlign="Top" />
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <HeaderStyle Font-Bold="True" ForeColor="White" HorizontalAlign="center" CssClass="standardistaTableSortingNoSort" />
                        <ItemTemplate>
                            <div style="width: 90px;">
                                <GraphBtn:WinampButton ID="ibEdit" runat="server" TemplateName="Edit" Text="Edit Info" />
                            </div>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="center" VerticalAlign="Top" />
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <HeaderStyle Font-Bold="True" ForeColor="White" HorizontalAlign="center" CssClass="standardistaTableSortingNoSort" />
                        <ItemTemplate>
                            <div style="width: 60px;">
                                <GraphBtn:WinampButton ID="ibAudit" runat="server" TemplateName="View" Text="Audit" />
                            </div>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="center" VerticalAlign="Top" />
                    </asp:TemplateField>
                </Columns>
                <%--<AlternatingRowStyle CssClass="RCIGridAlternating" />
                <HeaderStyle CssClass="RCIGridHeader" />
                <PagerStyle CssClass="RCIGridPager" />
                <RowStyle CssClass="RCIGridRow" />--%>
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" BorderStyle="Solid" BorderColor="#231F20" />
                <PagerStyle BackColor="#387C2B" ForeColor="White" HorizontalAlign="Left" Font-Bold="True"
                    Font-Names="Arial Black" Font-Overline="False" BorderStyle="Solid" BorderColor="#231F20" />
                <HeaderStyle BackColor="#387C2B" Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderColor="#231F20"/>
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <FooterStyle BackColor="#387C2B" Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderColor="#231F20"/>
                <EmptyDataTemplate>
                    <asp:Label ID="Label1" runat="server" Text="No procedures active!" />
                </EmptyDataTemplate>
            </asp:GridView>
        </td>
    </tr>
</table>

#Region "Private Members"
 
        Private DoReview As Boolean = False
        Dim MakeRed As Boolean = False
        Private RoleInteger As Integer = Null.NullInteger
        Private dtFiles As DataTable
        Private formCounts As DataTable
#End Region
 
#Region "Private Methods"
 
        Private Sub RedirectSelf()
            Response.Redirect(NavigateURL(TabId, "", _
                "SearchText=" & IIf(tbSearchTerm.Text.Trim = "", "notsearching", Server.UrlEncode(tbSearchTerm.Text)), _
                "SearchType=" & ddlSearchType.SelectedValue))
        End Sub
 
        Function DataTable2CSV(ByVal table As DataTable, Optional ByVal sepChar As String = ",") As Byte()
            Dim ms As New System.IO.MemoryStream
            Dim writer As System.IO.StreamWriter = Nothing
            Dim temp As String
 
            Try
                writer = New System.IO.StreamWriter(ms)
 
                ' first write a line with the columns name
                Dim sep As String = ""
                Dim builder As New System.Text.StringBuilder
                For Each col As DataColumn In table.Columns
                    builder.Append(sep).Append(col.ColumnName)
                    sep = sepChar
                Next
                writer.WriteLine(builder.ToString())
 
                ' then write all the rows
                For Each row As DataRow In table.Rows
                    sep = ""
                    builder = New System.Text.StringBuilder
 
                    For Each col As DataColumn In table.Columns
                        builder.Append(sep)
                        If row(col.ColumnName) Is System.DBNull.Value Then
                            temp = ""
                        Else
                            temp = row(col.ColumnName)
                        End If
                        If temp.Contains("""") OrElse temp.Contains(",") Then
                            temp = """" & temp.Replace("""", """""") & """"
                        End If
                        builder.Append(temp)
 
                        sep = sepChar
                    Next
                    writer.WriteLine(builder.ToString())
                Next
            Finally
                If Not writer Is Nothing Then writer.Close()
            End Try
 
            Dim b() As Byte = ms.ToArray
 
            Return b
        End Function
 
        Private Sub BindPolicyList()
            Try
 
                'KAW 2011-07-14
                'Task 221 - Add 'Edit Info' button option to QMS (Review)
                'For Edit Info Button
                formCounts = MyData.ProcTable("PolicyManual_GetFormCount", "@OwnerID", User.CorpID, "@QMS", 1, "@LocationID", lcLocation.LocationID)
 
                dtFiles = MyData.ProcTable("PolicyManual_GetFilesByOwner", "@CorpID", User.CorpID, "@QMS", 1)
                repSections.DataSource = MyData.ProcTable("PolicyManual_GetSectionsByBU", "@OwnerID", User.CorpID, "@QMS", 1, "@BUID", lcLocation.BUID, "@LocationID", lcLocation.LocationID)
                repSections.DataBind()
            Catch ex As Exception
                ProcessModuleLoadException("Error loading QMS Sections", Me, ex)
            End Try
        End Sub
 
        Private Sub BindPolicyListAlternateList()
            '  Try
 
            'KAW 2011-07-14
            'Task 221 - Add 'Edit Info' button option to QMS (Review)
            'For Edit Info Button
            formCounts = MyData.ProcTable("PolicyManual_GetFormCount", "@OwnerID", User.CorpID, "@QMS", 1, "@LocationID", lcLocation.LocationID)
 
            dtFiles = MyData.ProcTable("PolicyManual_GetFilesByOwner", "@CorpID", User.CorpID, "@QMS", 1)
 
            Dim aDataTable As DataTable = Nothing
 
            Select Case Me.rblProcedures.SelectedValue
                Case "1" 'facility procedures
                    'change this to only get procedures that are for the location
                    If tbSearchTerm.Text.Trim = "" Then
                        aDataTable = MyData.ProcTable("PolicyManual_GetPoliciesByLocationID_QMS", _
                            "@LocationID", lcLocation.LocationID, "@QMS", 1)
                    Else
                        Select Case ddlSearchType.SelectedValue
                            Case 0
                                aDataTable = MyData.ProcTable("PolicyManual_GetPoliciesByLocationID_QMS_SearchTitle", _
                                    "@LocationID", lcLocation.LocationID, "@TitleString", Me.tbSearchTerm.Text, "@QMS", 1)
                            Case 1
                                aDataTable = MyData.ProcTable("PolicyManual_GetPoliciesByLocationID_QMS_SearchDocNumber", _
                                    "@LocationID", lcLocation.LocationID, "@DocNumber", Me.tbSearchTerm.Text, "@QMS", 1)
                        End Select
                    End If
 
                Case Else 'corporate procedures
                    'change this to only get procedures that are corporate
                    If tbSearchTerm.Text.Trim = "" Then
                        aDataTable = MyData.ProcTable("PolicyManual_GetPoliciesByLocation", "@LocationID", lcLocation.LocationID, _
                            "@QMS", 1, "@OwnerID", User.CorpID)
                    Else
                        Select Case ddlSearchType.SelectedValue
                            Case 0 'search toitle
                                aDataTable = MyData.ProcTable("PolicyManual_GetPoliciesByLocation_SearchTitle", _
                                    "@LocationID", lcLocation.LocationID, "@QMS", 1, "@titlestring", Me.tbSearchTerm.Text, "@OwnerID", User.CorpID)
                            Case 1 ' search doc number
                                aDataTable = MyData.ProcTable("PolicyManual_GetPoliciesByLocation_SearchDocNumber", _
                                    "@LocationID", lcLocation.LocationID, "@QMS", 1, "@DocNumber", Me.tbSearchTerm.Text, "@OwnerID", User.CorpID)
                        End Select
                    End If
 
                    If DoReview Then
                        rgvNoSection.Columns(3).Visible = True
                    Else
                        rgvNoSection.Columns(3).Visible = False
                    End If
            End Select
 
            If aDataTable.Rows.Count > 0 Then
                rgvNoSection.DataSource = aDataTable
                rgvNoSection.DataBind()
 
                'MakeAccessible(gvNoSection)
            End If
 
            '            Catch ex As Exception
            '             ProcessModuleLoadException("Error loading QMS procedures", Me, ex)
            '            Response.Write(ex.ToString)
            '           End Try
        End Sub
 
        Private Sub AssignOwnerButton(ByVal thisButton As WinampButton, ByVal thisPolicy As Integer)
            If User.AuthLevel >= 39 Then
                Dim myAssignOwners As WinampButton = thisButton
                If myAssignOwners IsNot Nothing Then
                    myAssignOwners.Visible = True
                    myAssignOwners.OnClientClick = jsurf(EditUrl("policy", thisPolicy.ToString, "LocationOwners", "LocationID", lcLocation.LocationID.ToString))
                End If
            End If
        End Sub
 
        Private Sub AssignOwnerLink(ByVal thisLink As HyperLink, ByVal thisPolicy As Integer, ByVal DocOwnerName As String)
            Dim myAssignOwner As HyperLink = thisLink
            If myAssignOwner IsNot Nothing Then
                myAssignOwner.NavigateUrl = EditUrl("policy", thisPolicy.ToString, "LocationOwners", "LocationID", lcLocation.LocationID.ToString)
                myAssignOwner.Text = DocOwnerName
                myAssignOwner.Visible = True
            End If
        End Sub
 
        Private Sub AssignOwnersLabel(ByVal thisLabel As Label, ByVal OwnerName As String)
            Dim myAssignOwners As Label = thisLabel
            If myAssignOwners IsNot Nothing Then
                myAssignOwners.Text = OwnerName
                myAssignOwners.Visible = True
            End If
        End Sub
 
        Private Sub LastReviewLabel(ByVal thisLabel As Label, ByVal thisPolicy As Integer, ByVal thisVersion As Integer, ByVal ReviewDate As String)
            Dim myLastReview As Label = thisLabel
            If ReviewDate = "" Or ReviewDate <= New Date(1900, 1, 1) Then
                ReviewDate = "Not Reviewed"
            End If
            If myLastReview IsNot Nothing Then
                If MakeRed Then
                    myLastReview.Text = "<font color='red'>" & ReviewDate & "</font>"
                Else
                    myLastReview.Text = ReviewDate
                End If
                myLastReview.Visible = True
            End If
            MakeRed = False
        End Sub
 
#End Region
 
#Region "Page Methods"
 
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            DoReview = CBool(MyData.ProcScalar("Corps_ApplicationExists", "@CorpID", User.CorpID, "@ApplicationID", 65))
 
            Dim myScript As New StringBuilder
 
            With myScript
                .Append(" <script type='text/javascript' src='" & ResolveUrl("~/js/common.js") & "'></script>" & vbCrLf)
                .Append("<script type='text/javascript' src='" & ResolveUrl("~/js/css.js") & "'></script>" & vbCrLf)
                .Append("<script type='text/javascript' src='" & ResolveUrl("~/js/standardista-table-sorting.js") & "'></script>" & vbCrLf)
            End With
 
            If Not DotNetNuke.UI.Utilities.ClientAPI.IsClientScriptBlockRegistered(Page, "mySortTable") Then
                DotNetNuke.UI.Utilities.ClientAPI.RegisterClientScriptBlock(Page, "mySortTable", myScript.ToString)
            End If
        End Sub
 
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If lcLocation.LocationID > 0 Then
                Select Case RadioButtonList1.SelectedValue
                    Case "1"
                        If Page.IsPostBack = False Then
 
                            Me.cbExpandAll.Visible = False
                            Me.repSections.Visible = False
                            Me.rgvNoSection.Visible = True
                            BindPolicyListAlternateList() 'no categories
                        End If
                    Case Else
                        Me.cbExpandAll.Visible = True
                        Me.repSections.Visible = True
                        Me.rgvNoSection.Visible = False
                        BindPolicyList() 'this has categories
                End Select
            End If
        End Sub
 
        Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
            If Request.QueryString("SearchText") IsNot Nothing Then
                If Request.QueryString("SearchText") <> "notsearching" Then
                    tbSearchTerm.Text = Request.QueryString("SearchText")
                End If
            End If
 
            If Request.QueryString("SearchType") IsNot Nothing Then
                ddlSearchType.SelectedValue = Request.QueryString("SearchType")
            End If
 
            Dim a As Object
            a = DotNetNuke.Services.Personalization.Personalization.GetProfile("rblProcedures", "Selected") 'qms page malfunctioning here. this would actually run after
            If a IsNot Nothing Then                                                                         'the grid ran repeater ran its' itemdatabound w/ default of 0
                rblProcedures.SelectedValue = a                                                             'added these lines to the itemdatabound as well to correct this
            End If
 
            a = DotNetNuke.Services.Personalization.Personalization.GetProfile("PolicyType", "Selected")
            If a IsNot Nothing Then
                RadioButtonList1.SelectedValue = a
            End If
 
            a = DotNetNuke.Services.Personalization.Personalization.GetProfile("PolicyManualExpand", "Expanded")
            If a IsNot Nothing Then
                cbExpandAll.Checked = a
            End If
 
            If Request.QueryString("Type") IsNot Nothing Then
                Me.rblProcedures.SelectedIndex = CType(Request.QueryString("Type"), Integer)
            End If
            If Request.QueryString("Location") IsNot Nothing Then
                lcLocation.LocationID = CType(Request.QueryString("Location"), Integer)
            End If
            If RadioButtonList1.SelectedValue = 1 And lcLocation.LocationID > 0 Then
                Me.cbExpandAll.Visible = False
                Me.repSections.Visible = False
                Me.rgvNoSection.Visible = True
                BindPolicyListAlternateList()
            End If
        End Sub
 
#End Region
 
#Region "Event Handlers"
 
        Protected Sub repSections_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repSections.ItemDataBound
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
 
                'lbSectionName
                Dim myLabel As New RCI.Modules.RCIWebApps_SectionHeadControl
                myLabel = CType(e.Item.FindControl("dshModule"), RCI.Modules.RCIWebApps_SectionHeadControl)
                myLabel.Text = "<font color=white>" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "SectionName")) & "</font>"
                If Me.cbExpandAll.Checked Then
                    myLabel.IgnorePersonalization = True
                    myLabel.IsExpanded = True
                End If
 
                Dim myRGV As RadGrid = CType(e.Item.FindControl("rgvSection"), RadGridid)
                Dim aDataTable As New DataTable
 
                If Page.IsPostBack = False Then
                    Dim a As Object
                    a = DotNetNuke.Services.Personalization.Personalization.GetProfile("rblProcedures", "Selected")
                    If a IsNot Nothing Then
                        rblProcedures.SelectedValue = a
                    End If
                End If
                Select Case Me.rblProcedures.SelectedValue
                    Case "1" 'facility procedures
                        'change this to only get procedures that are for the location
                        Select Case ddlSearchType.SelectedValue
                            Case 0
                                aDataTable = MyData.ProcTable("GetPoliciesBySectionByLocationID_QMS_SearchTitle", _
                                    "@LocationID", lcLocation.LocationID, "@SectionID", Convert.ToInt32(e.Item.DataItem("ID")), _
                                    "@QMS", 1, "@titlestring", Me.tbSearchTerm.Text)
                            Case 1
                                aDataTable = MyData.ProcTable("GetPoliciesBySectionByLocationID_QMS_SearchDocNumber", _
                                    "@LocationID", lcLocation.LocationID, "@SectionID", Convert.ToInt32(e.Item.DataItem("ID")), _
                                    "@QMS", 1, "@DocNumber", Me.tbSearchTerm.Text)
                            Case Else
                                aDataTable = MyData.ProcTable("GetPoliciesBySectionByLocationID_QMS", _
                                    "@LocationID", lcLocation.LocationID, "@SectionID", Convert.ToInt32(e.Item.DataItem("ID")), _
                                    "@QMS", 1)
                        End Select
                    Case Else 'corporate procedures
                        'change this to only get procedures that are corporate
                        Select Case ddlSearchType.SelectedValue
                            Case 0 'search toitle
                                aDataTable = MyData.ProcTable("GetPoliciesBySectionByLocation_SearchTitle", _
                                   "@LocationID", lcLocation.LocationID, "@SectionID", Convert.ToInt32(e.Item.DataItem("ID")), _
                                   "@QMS", 1, "@titlestring", Me.tbSearchTerm.Text)
                            Case 1 ' search doc number
                                aDataTable = MyData.ProcTable("GetPoliciesBySectionByLocation_SearchDocNumber", _
                                   "@LocationID", lcLocation.LocationID, "@SectionID", Convert.ToInt32(e.Item.DataItem("ID")), _
                                   "@QMS", 1, "@DocNumber", Me.tbSearchTerm.Text)
                            Case Else
                                aDataTable = MyData.ProcTable("GetPoliciesBySectionByLocation", _
                                   "@LocationID", lcLocation.LocationID, "@SectionID", Convert.ToInt32(e.Item.DataItem("ID")), _
                                   "@QMS", 1)
                        End Select
 
                        If DoReview Then
                            myRGV.Columns(3).Visible = True
                        Else
                            myRGV.Columns(3).Visible = False
                        End If
                End Select
 
                myRGV.DataSource = aDataTable
                myRGV.DataBind()
 
 
                'this section is for email links
                'it pops open the section if its closed when the link to the
                'changed policy is used
                If Request.QueryString("Expand") IsNot Nothing Then
                    Dim AnchorURL As String = Request.QueryString("Expand").ToString
                    Dim LinkView As DataView = New DataView(aDataTable, "  ID = " & AnchorURL & " ", "SortOrder", DataViewRowState.CurrentRows)
 
                    If LinkView.Count > 0 Then
                        myLabel.IgnorePersonalization = True
                        myLabel.IsExpanded = True
                    End If
                End If
            End If
        End Sub
 
        Protected Sub rgvSection_NeedDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs)
 
        End Sub
 
        Protected Sub rgvSection_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
 
            If TypeOf e.Item Is GridDataItem Then
                If Request.QueryString("Expand") IsNot Nothing Then
                    Dim AnchorURL As Integer = CType(Request.QueryString("Expand"), Integer)
                    If AnchorURL = CType(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID"), Integer) Then
                        'highlight row
                        e.Item.CssClass = "GridExpandAlert"
                    End If
                End If
                'litPolicy
                Dim myLiteral As New Label
                myLiteral = CType(e.Item.FindControl("lblPolicyName2"), Label)
 
                Dim myLabel As String = Null.NullString
                myLabel = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "PolicyName"))
                If myLiteral IsNot Nothing Then
                    myLiteral.Text = "<a name=""" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")) & """></a>" & myLabel
                End If
 
                myLiteral = New Label
                myLiteral = CType(e.Item.FindControl("lblDocnumber2"), Label)
                If Not System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DocNumber") Is System.DBNull.Value And Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DocNumber")).Trim.Length > 0 Then
                    If myLiteral IsNot Nothing Then
                        myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DocNumber"))
                    End If
                End If
 
                myLiteral = New Label
                myLiteral = CType(e.Item.FindControl("lblDocOwner2"), Label)
                If myLiteral IsNot Nothing Then
                    myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DisplayName"))
                End If
                myLiteral = New Label
                myLiteral = CType(e.Item.FindControl("lblUpdate2"), Label)
                If myLiteral IsNot Nothing Then
                    myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "DateEntered"))
                End If
                If DoReview Then
                    Dim myLocOwner As DataTable = MyData.ProcTable("PolicyManual_GetLocationOwner", "@PolicyID", e.Item.DataItem("ID"), "@LocationID", lcLocation.LocationID)
                    Dim myLastReviewDateTable As DataTable = MyData.ProcTable("PolicyManual_GetLastLocationReview", "@PolicyID", e.Item.DataItem("ID"), "@Version", e.Item.DataItem("PolicyTextID"), "@LocationID", lcLocation.LocationID)
                    Dim myLastReviewDate As String
                    If myLastReviewDateTable.Rows.Count < 1 Then
                        myLastReviewDate = "1/1/1900"
                    Else
                        myLastReviewDate = myLastReviewDateTable.Rows(0).Item("LastReviewDate")
                    End If
                    If DateAdd("M", e.Item.DataItem("ReviewFrequency"), myLastReviewDate) <= Now() Then
                        MakeRed = True
                    Else
                        MakeRed = False
                    End If
 
                    If myLocOwner.Rows.Count > 0 Then
                        If Not IsDBNull(myLocOwner.Rows(0).Item("DocOwner")) Then
                            If User.AuthLevel >= 39 Then
                                If myLocOwner.Rows(0).Item("DocOwnerName").ToString.Trim() <> "" Then
                                    AssignOwnerLink(CType(e.Item.FindControl("hypAssignLocationOwners2"), HyperLink), e.Item.DataItem("ID"), myLocOwner.Rows(0).Item("DocOwnerName"))
                                Else
                                    AssignOwnerButton(CType(e.Item.FindControl("btnAssignLocationOwners2"), WinampButton), e.Item.DataItem("ID"))
                                End If
                            Else
                                AssignOwnersLabel(CType(e.Item.FindControl("lblAssignLocationOwners"), Label), myLocOwner.Rows(0).Item("DocOwnerName"))
                            End If
 
                            If User.UserID = myLocOwner.Rows(0).Item("DocOwner") Then
                                If myLastReviewDate = "" Then
                                    Dim myLastReview As WinampButton = CType(e.Item.FindControl("btnReview2"), WinampButton)
                                    If myLastReview IsNot Nothing Then
                                        myLastReview.OnClientClick = jsurf(EditUrl("PolicyID", e.Item.DataItem("ID").ToString, "Review", "PolicyVersion", e.Item.DataItem("PolicyTextID").ToString, "LocationID", lcLocation.LocationID.ToString))
                                        myLastReview.Visible = True
                                    End If
                                Else
                                    Dim myLastReview As HyperLink = CType(e.Item.FindControl("hypReview2"), HyperLink)
                                    If myLastReview IsNot Nothing Then
                                        myLastReview.NavigateUrl = EditUrl("PolicyID", e.Item.DataItem("ID").ToString, "Review", "PolicyVersion", e.Item.DataItem("PolicyTextID2").ToString, "LocationID", lcLocation.LocationID.ToString)
                                    End If
                                    If myLastReviewDate = "" Or myLastReviewDate <= New Date(1900, 1, 1) Then
                                        myLastReviewDate = "Not Reviewed"
                                    End If
                                    If MakeRed Then
                                        myLastReviewDate = "<font color='red'>" & myLastReviewDate & "</font>"
                                    End If
                                    If myLastReview IsNot Nothing Then
                                        myLastReview.Text = myLastReviewDate
                                        myLastReview.Visible = True
                                    End If
                                    MakeRed = False
                                End If
                            Else
                                LastReviewLabel(CType(e.Item.FindControl("lblReview"), Label), e.Item.DataItem("ID"), e.Item.DataItem("PolicyTextID"), myLastReviewDate)
                            End If
                        Else
                            AssignOwnerButton(CType(e.Item.FindControl("btnAssignLocationOwners2"), WinampButton), e.Item.DataItem("ID"))
                            LastReviewLabel(CType(e.Item.FindControl("lblReview2"), Label), e.Item.DataItem("ID"), e.Item.DataItem("PolicyTextID"), myLastReviewDate)
                        End If
                    Else
                        AssignOwnerButton(CType(e.Item.FindControl("btnAssignLocationOwners2"), WinampButton), e.Item.DataItem("ID"))
                        LastReviewLabel(CType(e.Item.FindControl("lblReview2"), Label), e.Item.DataItem("ID"), e.Item.DataItem("PolicyTextID"), myLastReviewDate)
                    End If
                End If
 
                Dim myAuditLink As New WinampButton
                myAuditLink = CType(e.Item.FindControl("ibAudit2"), WinampButton)
                If myAuditLink IsNot Nothing Then
                    If Convert.ToBoolean(e.Item.DataItem("ShowAuditQuestions")) = True Then
                        If myAuditLink IsNot Nothing Then
                            myAuditLink.Visible = True
                            myAuditLink.OnClientClick = "document.location.href='" & EditUrl("policy", Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")), "Audit") & "';"
                            myAuditLink.CausesPostback = False
                        End If
                    Else
                        myAuditLink.Visible = False
                    End If
                End If
                'need to find and load file link control here
                Dim myFiles As FileUpload = CType(e.Item.FindControl("FileLinkControl12"), FileUpload)
                If myFiles IsNot Nothing Then
                    myFiles.DataSource = New DataView(dtFiles, "PolicyID=" & e.Item.DataItem("ID"), "FriendlyName", DataViewRowState.CurrentRows).ToTable
                    '   myFiles.DataSource = myData.TextTable("SELECT a.fileid, c.* FROM PolicyManual_Files a WITH (NOLOCK) INNER JOIN PolicyManual_NewestPolicy_Version b WITH (NOLOCK) ON a.VersionID = b.ID INNER JOIN Generic_File AS c WITH (NOLOCK) ON a.FileID = c.ID WHERE b.PolicyID = @PolicyID ORDER BY c.FriendlyName", "@PolicyID", System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID"))
 
                    If myFiles.DataSource.Rows.Count < 1 Then
                        myFiles.Visible = False
                    End If
                End If
 
                'KAW 2011-07-14
                'Task 221 - Add 'Edit Info' button option to QMS (Review)
                'For Edit Info Button
                Dim myDataLink As New WinampButton
                myDataLink = CType(e.Item.FindControl("ibEdit2"), WinampButton)
 
                'Figure if we have forms to show
                Dim myView As DataView
                myView = New DataView(formCounts, " PolicyID =" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")) & " ", "", DataViewRowState.CurrentRows)
                If myView.Count > 0 Then
                    If myDataLink IsNot Nothing Then
                        myDataLink.Visible = True
                        myDataLink.OnClientClick = "document.location.href='" & EditUrl("policy", Convert.ToString(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "ID")), "Menu") & "';"
                        myDataLink.CausesPostback = False
                    End If
                Else
                    If myDataLink IsNot Nothing Then
                        myDataLink.Visible = False
                    End If
                End If
 
                Dim myPrintLink As New WinampButton
                myPrintLink = CType(e.Item.FindControl("ibPrintPolicy2"), WinampButton)
                If myPrintLink IsNot Nothing Then
                    myPrintLink.OnClientClick = jsurf(EditUrl("policy", e.Item.DataItem("ID").ToString, "Print", "ExcludeViewStateCache=True", "LocID=" & lcLocation.LocationID.ToString))
                    myPrintLink.CausesPostback = False
                End If
            End If
        End Sub
 
        Protected Sub rgvSection_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs)
 
            'If e.CommandName = RadGrid.ExportToWordCommandName Then
            '    rgvNoSection.ExportSettings.ExportOnlyData = True
            '    rgvNoSection.Rebind()
            '    e.Item.OwnerTableView.CommandItemDisplay = False
            '    'complete list (rgvNoSection) has trouble exporting. Doesnt do it correctly, shows hyperlinks, buttons, and command items.
            '    'this was my test case. was able to get rid of the command items, but none of the others.
            'End If
 
        End Sub
 
        Protected Sub rgvSection_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles rgvNoSection.ItemCreated
             
        End Sub
 
 
        Protected Sub repSections_ItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles repSections.ItemCreated
            Dim myRGVDataList As New RadGrid
 
            myRGVDataList = CType(e.Item.FindControl("rgvSection"), RadGrid)
        End Sub
 
        Protected Sub gvSection_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
            If e.Row.RowType = DataControlRowType.DataRow Then
                If Request.QueryString("Expand") IsNot Nothing Then
                    Dim AnchorURL As Integer = CType(Request.QueryString("Expand"), Integer)
                    If AnchorURL = CType(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID"), Integer) Then
                        'highlight row
                        e.Row.CssClass = "GridExpandAlert"
                    End If
                End If
                'litPolicy
                Dim myLiteral As New Label
                myLiteral = CType(e.Row.FindControl("lblPolicyName"), Label)
 
                Dim myLabel As String = Null.NullString
                myLabel = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "PolicyName"))
                myLiteral.Text = "<a name=""" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID")) & """></a>" & myLabel
 
                myLiteral = New Label
                myLiteral = CType(e.Row.FindControl("lblDocnumber"), Label)
                If Not System.Web.UI.DataBinder.Eval(e.Row.DataItem, "DocNumber") Is System.DBNull.Value And Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "DocNumber")).Trim.Length > 0 Then
                    myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "DocNumber"))
                End If
 
                myLiteral = New Label
                myLiteral = CType(e.Row.FindControl("lblDocOwner"), Label)
                myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "DisplayName"))
                myLiteral = New Label
                myLiteral = CType(e.Row.FindControl("lblUpdate"), Label)
                myLiteral.Text = Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "DateEntered"))
 
                If DoReview Then
                    Dim myLocOwner As DataTable = MyData.ProcTable("PolicyManual_GetLocationOwner", "@PolicyID", e.Row.DataItem("ID"), "@LocationID", lcLocation.LocationID)
                    Dim myLastReviewDateTable As DataTable = MyData.ProcTable("PolicyManual_GetLastLocationReview", "@PolicyID", e.Row.DataItem("ID"), "@Version", e.Row.DataItem("PolicyTextID"), "@LocationID", lcLocation.LocationID)
                    Dim myLastReviewDate As String
                    If myLastReviewDateTable.Rows.Count < 1 Then
                        myLastReviewDate = "1/1/1900"
                    Else
                        myLastReviewDate = myLastReviewDateTable.Rows(0).Item("LastReviewDate")
                    End If
                    If DateAdd("M", e.Row.DataItem("ReviewFrequency"), myLastReviewDate) <= Now() Then
                        MakeRed = True
                    Else
                        MakeRed = False
                    End If
 
                    If myLocOwner.Rows.Count > 0 Then
                        If Not IsDBNull(myLocOwner.Rows(0).Item("DocOwner")) Then
                            If User.AuthLevel >= 39 Then
                                If myLocOwner.Rows(0).Item("DocOwnerName").ToString.Trim() <> "" Then
                                    AssignOwnerLink(CType(e.Row.FindControl("hypAssignLocationOwners"), HyperLink), e.Row.DataItem("ID"), myLocOwner.Rows(0).Item("DocOwnerName"))
                                Else
                                    AssignOwnerButton(CType(e.Row.FindControl("btnAssignLocationOwners"), WinampButton), e.Row.DataItem("ID"))
                                End If
                            Else
                                AssignOwnersLabel(CType(e.Row.FindControl("lblAssignLocationOwners"), Label), myLocOwner.Rows(0).Item("DocOwnerName"))
                            End If
 
                            If User.UserID = myLocOwner.Rows(0).Item("DocOwner") Then
                                If myLastReviewDate = "" Then
                                    Dim myLastReview As WinampButton = CType(e.Row.FindControl("btnReview"), WinampButton)
                                    myLastReview.OnClientClick = jsurf(EditUrl("PolicyID", e.Row.DataItem("ID").ToString, "Review", "PolicyVersion", e.Row.DataItem("PolicyTextID").ToString, "LocationID", lcLocation.LocationID.ToString))
                                    myLastReview.Visible = True
                                Else
                                    Dim myLastReview As HyperLink = CType(e.Row.FindControl("hypReview"), HyperLink)
                                    myLastReview.NavigateUrl = EditUrl("PolicyID", e.Row.DataItem("ID").ToString, "Review", "PolicyVersion", e.Row.DataItem("PolicyTextID").ToString, "LocationID", lcLocation.LocationID.ToString)
                                    If myLastReviewDate = "" Or myLastReviewDate <= New Date(1900, 1, 1) Then
                                        myLastReviewDate = "Not Reviewed"
                                    End If
                                    If MakeRed Then
                                        myLastReviewDate = "<font color='red'>" & myLastReviewDate & "</font>"
                                    End If
                                    myLastReview.Text = myLastReviewDate
                                    myLastReview.Visible = True
                                    MakeRed = False
                                End If
                            Else
                                LastReviewLabel(CType(e.Row.FindControl("lblReview"), Label), e.Row.DataItem("ID"), e.Row.DataItem("PolicyTextID"), myLastReviewDate)
                            End If
                        Else
                            AssignOwnerButton(CType(e.Row.FindControl("btnAssignLocationOwners"), WinampButton), e.Row.DataItem("ID"))
                            LastReviewLabel(CType(e.Row.FindControl("lblReview"), Label), e.Row.DataItem("ID"), e.Row.DataItem("PolicyTextID"), myLastReviewDate)
                        End If
                    Else
                        AssignOwnerButton(CType(e.Row.FindControl("btnAssignLocationOwners"), WinampButton), e.Row.DataItem("ID"))
                        LastReviewLabel(CType(e.Row.FindControl("lblReview"), Label), e.Row.DataItem("ID"), e.Row.DataItem("PolicyTextID"), myLastReviewDate)
                    End If
                End If
 
                Dim myAuditLink As New WinampButton
                myAuditLink = CType(e.Row.FindControl("ibAudit"), WinampButton)
                If Convert.ToBoolean(e.Row.DataItem("ShowAuditQuestions")) = True Then
                    myAuditLink.Visible = True
                    myAuditLink.OnClientClick = "document.location.href='" & EditUrl("policy", Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID")), "Audit") & "';"
                    myAuditLink.CausesPostback = False
                Else
                    myAuditLink.Visible = False
                End If
 
                'need to find and load file link control here
                Dim myFiles As FileUpload = CType(e.Row.FindControl("FileLinkControl1"), FileUpload)
                myFiles.DataSource = New DataView(dtFiles, "PolicyID=" & e.Row.DataItem("ID"), "FriendlyName", DataViewRowState.CurrentRows).ToTable
                '   myFiles.DataSource = myData.TextTable("SELECT a.fileid, c.* FROM PolicyManual_Files a WITH (NOLOCK) INNER JOIN PolicyManual_NewestPolicy_Version b WITH (NOLOCK) ON a.VersionID = b.ID INNER JOIN Generic_File AS c WITH (NOLOCK) ON a.FileID = c.ID WHERE b.PolicyID = @PolicyID ORDER BY c.FriendlyName", "@PolicyID", System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID"))
 
                If myFiles.DataSource.Rows.Count < 1 Then
                    myFiles.Visible = False
                End If
 
                'KAW 2011-07-14
                'Task 221 - Add 'Edit Info' button option to QMS (Review)
                'For Edit Info Button
                Dim myDataLink As New WinampButton
                myDataLink = CType(e.Row.FindControl("ibEdit"), WinampButton)
 
                'Figure if we have forms to show
                Dim myView As DataView
                myView = New DataView(formCounts, " PolicyID =" & Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID")) & " ", "", DataViewRowState.CurrentRows)
                If myView.Count > 0 Then
                    myDataLink.Visible = True
                    myDataLink.OnClientClick = "document.location.href='" & EditUrl("policy", Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ID")), "Menu") & "';"
                    myDataLink.CausesPostback = False
                Else
                    myDataLink.Visible = False
                End If
 
                Dim myPrintLink As New WinampButton
                myPrintLink = CType(e.Row.FindControl("ibPrintPolicy"), WinampButton)
                myPrintLink.OnClientClick = jsurf(EditUrl("policy", e.Row.DataItem("ID").ToString, "Print", "ExcludeViewStateCache=True", "LocID=" & lcLocation.LocationID.ToString))
                myPrintLink.CausesPostback = False
            End If
 
        End Sub
 
        Protected Sub rblProcedures_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblProcedures.SelectedIndexChanged
            DotNetNuke.Services.Personalization.Personalization.SetProfile("rblProcedures", "Selected", rblProcedures.SelectedValue)
 
            RedirectSelf()
        End Sub
 
        Protected Sub clearsearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles clearsearch.Click
            Me.tbSearchTerm.Text = Null.NullString
 
            RedirectSelf()
        End Sub
 
        Protected Sub runsearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles runsearch.Click
            RedirectSelf()
        End Sub
 
        Protected Sub gbPrintMasterList_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles gbPrintMasterList.Click
            If Me.tbSearchTerm.Text.Length > 0 Then
                Response.Redirect(EditUrl("Location", lcLocation.LocationID.ToString, "MasterPrint", "Proc=" & Me.rblProcedures.SelectedValue.ToString, "sType=" & Me.ddlSearchType.SelectedValue.ToString, "Terms=" & Me.tbSearchTerm.Text, "Corp=" & User.CorpID.ToString), True)
            Else
                Response.Redirect(EditUrl("Location", lcLocation.LocationID.ToString, "MasterPrint", "Proc=" & Me.rblProcedures.SelectedValue.ToString, "Corp=" & User.CorpID.ToString), True)
            End If
        End Sub
 
        Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
            DotNetNuke.Services.Personalization.Personalization.SetProfile("PolicyType", "Selected", Me.RadioButtonList1.SelectedValue)
 
            RedirectSelf()
        End Sub
 
        Protected Sub cbExpandAll_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbExpandAll.CheckedChanged
            DotNetNuke.Services.Personalization.Personalization.SetProfile("PolicyManualExpand", "Expanded", Me.cbExpandAll.Checked.ToString)
            RedirectSelf()
        End Sub
 
        Protected Sub lcLocation_DropDownChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lcLocation.DropDownChanged
            If Page.IsPostBack Then
                RedirectSelf()
            End If
        End Sub
 
        Protected Sub btnExportMasterList_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnExportMasterList.Click
            Dim export As DataTable
            If rblProcedures.SelectedValue = 0 Then
                export = MyData.ProcTable("PolicyManual_GetPoliciesByLocation", "@LocationID", lcLocation.LocationID, "@QMS", 1, "@OwnerID", User.CorpID)
            Else
                export = MyData.ProcTable("PolicyManual_GetPoliciesByLocationID_QMS", "@LocationID", lcLocation.LocationID, "@QMS", 1)
            End If
 
            'fix for excel, otherwise it thinks its a SYLK file (if first two chars are ID
            export.Columns.RemoveAt(0)
 
            Dim b = DataTable2CSV(export)
 
            Context.Response.Clear()
            Response.ClearHeaders()
            Context.Response.AddHeader("Content-Disposition", "Attachment; filename=MasterListExport.csv")
            Context.Response.ContentType = "application/vnd.ms-excel"
            Context.Response.BinaryWrite(b)
            Context.Response.End()
        End Sub
 
        Private Sub MakeAccessible(ByVal myGrid As GridView)
            If (myGrid.Rows.Count > 0) Then
                myGrid.UseAccessibleHeader = True
                myGrid.HeaderRow.TableSection = TableRowSection.TableHeader
                myGrid.FooterRow.TableSection = TableRowSection.TableFooter
            End If
        End Sub
#End Region
 
    End Class
 
End Namespace

This is the grid that has the issues at hand.

http://i.imgur.com/fNjR3W6.png

While these grids are all the exact same and have their exports work.

http://i.imgur.com/DZXwMQy.png

Thanks to anyone who attempts to check this problem out. I know its lengthy! I would even go as far as hugging you if I ever found you in real life!
0
Kostadin
Telerik team
answered on 29 Jul 2014, 11:18 AM
Hi Alexander,

I notice that you are binding the grids by using a simple databinding. Please know that exporting a grid bind this way is not supported. Please make sure you are binding the grid by using the advanced data-binding approach as described in the following help article and let me know about the result. If you still experience the issue I would appreciate if you could provide a simplify runnable sample in order to investigate it further.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexander
Top achievements
Rank 1
answered on 29 Jul 2014, 03:03 PM
Wouldn't the line:
OnNeedDataSource="rgvSection_NeedDataSource"
take care of the binding issues?

And I thank you so much Kostadin  for even attempting to help me after what I posted there, haha!
Also, I think I am just going to remove the export from the grid and call it a day. It is turning out to be too much of a hassle than it's worth.

Again, thanks a million for even attempting!
0
Kostadin
Telerik team
answered on 01 Aug 2014, 07:55 AM
Hi Alexander,

NeedDataSource event is called automatically each time when the grid's needs to be bound to its datasource. So generally in the event you need to set the DataSource of the grid and and all the built-in features should work properly.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Kostadin
Telerik team
Share this question
or