Hello Telerik Team,
I am trying to export the values of the child of a RadGrid but it shows "No child records to display" when use gvDoNotCall.MasterTableView.HierarchyDefaultExpanded = true
I attached the code and an image of the grid
Thank you very much
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="DoNotCall.aspx.cs" Inherits="DoNotCall" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Import Namespace="Com.PromptAlert.PAPortalCommon" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<style type="text/css">
.strikethrough
{
text-decoration: line-through;
}
.rightalign
{
float:right;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
//We obtain the button we want to hit as default
$(document).keypress(function (e) {
var defaultButton = $("[id$=bnSearch]");
setEnterValue(e, defaultButton);
});
});
</script>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
args.get_eventTarget().indexOf("ExportToPdfButton") >= 0) {
args.set_enableAjax(false);
if (!confirm("You are exporting information potentially containing Protected Health Information (PHI) and/or Personally Identifiable Information (PII). Please click OK to proceed or Cancel to return to the previous screen")) { return false; }
}
}
</script>
</telerik:RadScriptBlock>
<h1 class="page-title">
Do Not Call List</h1>
<div class="box">
<%--<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">--%>
<div class="field-box" id="valSumm">
<asp:ValidationSummary CssClass="error-label" ID="valSummary" runat="server" HeaderText="The following errors occurred on the page: ">
</asp:ValidationSummary>
</div>
<div class="field-box">
<asp:Label CssClass="left-field" ID="lblSearchPhoneNumber" runat="server" Text="Search Phone Number:"></asp:Label>
<asp:TextBox CssClass="right-field" runat="server" ID="txtSearchPhoneNumber" ValidationGroup="vgroup2"></asp:TextBox>
<span>*
<asp:RegularExpressionValidator CssClass="error-label" ID="regexPhone1" runat="server" ValidationExpression="^(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$" ValidationGroup="vgroup2"
ControlToValidate="txtSearchPhoneNumber" ErrorMessage="Invalid Phone Format" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator CssClass="error-label" ID="rfPhone1" runat="server" ErrorMessage="Please enter a valid phone number" ValidationGroup="vgroup2"
ControlToValidate="txtSearchPhoneNumber" Display="Dynamic"></asp:RequiredFieldValidator>
</span>
</div>
<div class="field-box">
<asp:Button runat="server" Text="Search" CssClass="action-button left-field" value="Search" ID="bnSearch" ValidationGroup="vgroup2" OnClick="bnSearch_Click"/>
<asp:Button runat="server" Text="Clear Search" CssClass="action-button right-field" value="ClearSearch" ID="bnClearSearch" CausesValidation="false" OnClick="bnClearSearch_Click"/>
<asp:Label CssClass="rightalign" ID="Label1" runat="server" Text="Strike through phone number is <div style='display: inline-block;color:red;'>NOT</div> included in Do Not Call list"></asp:Label>
</div>
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" ClientEvents-OnRequestStart="onRequestStart">
<telerik:RadGrid ID="gvDoNotCall" runat="server" AllowFilteringByColumn="false" AllowPaging="True"
AllowSorting="True" CellSpacing="0" GridLines="None" PageSize="10" OnNeedDataSource="gvDoNotCall_NeedDataSource"
AutoGenerateColumns="false" OnItemCommand="gvDoNotCall_ItemCommand" OnDeleteCommand="gvDoNotCall_DeleteCommand" OnItemDataBound="gvDoNotCall_ItemDataBound"
OnInsertCommand="gvDoNotCall_InsertCommand" OnUpdateCommand="gvDoNotCall_UpdateCommand" OnItemCreated="gvDoNotCall_ItemCreated" AutoGenerateHierarchy="true"
OnPageIndexChanging="gvDoNotCall_PageIndexChanging">
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<DetailTables>
<telerik:GridTableView Name="tblClients" DataKeyNames="HomePhone"
Width="100%" NoDetailRecordsText="No Client for this number"
AllowFilteringByColumn="false" AllowPaging="false">
<Columns>
<telerik:GridBoundColumn UniqueName="ClientRecordNumber" HeaderText="MRN" DataField="ClientRecordNumber" />
<telerik:GridBoundColumn UniqueName="FirstName" HeaderText="Client First Name"
DataField="FirstName" />
<telerik:GridBoundColumn UniqueName="LastName" HeaderText="Client Last Name"
DataField="LastName" />
<telerik:GridDateTimeColumn UniqueName="DateOfBirth" HeaderText="Date Of Birth" DataField="DateOfBirth"
AllowFiltering="false" DataFormatString="{0:dd MMM yyyy}" />
<telerik:GridBoundColumn UniqueName="PrimaryNumber" HeaderText="Primary Number"
DataField="PrimaryNumber" />
<telerik:GridBoundColumn UniqueName="SecondaryNumber" HeaderText="Secondary Number"
DataField="SecondaryNumber" />
<telerik:GridBoundColumn UniqueName="MatchedNumber" HeaderText="Matched Number" Display="false"
DataField="MatchedNumber" />
<telerik:GridBoundColumn UniqueName="MatchedBoth" HeaderText="Matched Both" Display="false"
DataField="MatchedBoth" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridButtonColumn UniqueName="EditButtonId" ButtonCssClass="edit-button" ButtonType="ImageButton" CommandName="Edit" HeaderText="Edit" ImageUrl="../App_Themes/Modern/images/edit-button.png" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"/>
<telerik:GridButtonColumn UniqueName="DeleteButtonId" ButtonCssClass="delete-button" HeaderText="Delete" ConfirmText="Delete this do not call entry?" ConfirmDialogType="Classic" HeaderStyle-HorizontalAlign="Center"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"
ConfirmDialogWidth="220px" ImageUrl="../App_Themes/Modern/images/delete-button.png" HeaderStyle-Width="100px" />
<telerik:GridBoundColumn UniqueName="Id" HeaderText="Id" DataField="Id" ReadOnly="true"
Visible="false" />
<telerik:GridTemplateColumn UniqueName="PhoneNumber" HeaderText="Phone Number" DataField="PhoneNumber">
<ItemTemplate>
<asp:Label runat="server" ID="lblPhoneNumber" Text='<%# Eval("PhoneNumber") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtPhoneNumber" Text='<%# Bind("PhoneNumber") %>' ValidationGroup="vgroup1"></asp:TextBox>
<span>*
<asp:RegularExpressionValidator CssClass="error-label" ID="regexPhone2" runat="server" ValidationExpression="^(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$" ValidationGroup="vgroup1"
ControlToValidate="txtPhoneNumber" ErrorMessage="Invalid Phone Format" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator CssClass="error-label" ID="rfPhone2" runat="server" ErrorMessage="Please enter a valid phone number" ValidationGroup="vgroup1"
ControlToValidate="txtPhoneNumber" Display="Dynamic"></asp:RequiredFieldValidator>
</span>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="LastUpdatedBy" HeaderText="Last Updated By"
DataField="LastUpdatedUserId">
<ItemTemplate>
<asp:Label runat="server" ID="LastUpdatedUserId" Text='<%# Utility.GetUserNameByIdStaff(Convert.ToInt32(Eval("LastUpdatedUserId"))) %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn UniqueName="LastUpdatedDateTime" HeaderText="Last Updated Date"
DataField="LastUpdatedDateTime" ReadOnly="true" />
<telerik:GridTemplateColumn UniqueName="InsertButton" HeaderText="">
<EditItemTemplate>
<%--<asp:TextBox runat="server" ID="txtPhoneNumber" Text='<%# Bind("PhoneNumber") %>'></asp:TextBox>--%>
<asp:Button ID="btSaveNew" runat="server" CssClass="action-button" Text="Save and New" CommandName="SaveNew" Visible="false" ValidationGroup="vgroup1"></asp:Button>
<asp:Button ID="btSaveClose" runat="server" CssClass="action-button" Text="Save and Close" CommandName="SaveClose" Visible="false" ValidationGroup="vgroup1"></asp:Button>
<asp:Button ID="btCancel" runat="server" CssClass="action-button" Text="Cancel" CommandName="CancelButton" Visible="false" CausesValidation="false"></asp:Button>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<CommandItemSettings ShowExportToExcelButton="true" ShowExportToWordButton="true"
ShowExportToPdfButton="true" ShowAddNewRecordButton="true" ShowRefreshButton="true" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
<Excel Format="Html" />
</ExportSettings>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
<ValidationSettings CommandsToValidate="PerformInsert,Update" />
</telerik:RadGrid>
</telerik:RadAjaxPanel>
<telerik:RadWindowManager runat="server" ID="RadWindowManager1" Title="PatientPrompt.com"
InitialBehaviors="Default" KeepInScreenBounds="true">
</telerik:RadWindowManager>
<%--<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />--%>
</div>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
// logging imports
using log4net;
using log4net.Appender;
using log4net.Config;
using Telerik.Web.UI;
using Com.PromptAlert.PAPortalCommon.Dao;
using Com.PromptAlert.PAPortalCommon;
using Com.PromptAlert.PAPortalCommon.Domain;
using DoNotCallOjb = Com.PromptAlert.Domain.DoNotCall;
public partial class DoNotCall : System.Web.UI.Page
{
// define loggers
public static readonly ILog log = LogManager.GetLogger("Account_DoNotCall.aspx.cs");
private bool isExport = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillGrid();
}
//LinkButton UpdateButton = (LinkButton)e.Item.FindControl("UpdateButton");
txtSearchPhoneNumber.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + bnSearch.ClientID + "').click();return false;}} else {return true}; ");
}
protected void gvDoNotCall_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName.Contains("Export"))
{
isExport = true;
gvDoNotCall.MasterTableView.GetColumn("EditButtonId").Visible = false;
gvDoNotCall.MasterTableView.GetColumn("DeleteButtonId").Visible = false;
// gvDoNotCall.MasterTableView.HierarchyDefaultExpanded = true;
}
if (e.CommandName.Contains("SaveClose"))
{
if (e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
DoNotCallOjb dnc = new DoNotCallOjb();
item.UpdateValues(dnc);
AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
//gvDoNotCall.MasterTableView.IsItemInserted = true;
//FillGrid();
Response.Redirect("~/dashboard");
}
}
if (e.CommandName.Contains("SaveNew"))
{
if (e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
DoNotCallOjb dnc = new DoNotCallOjb();
item.UpdateValues(dnc);
AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
gvDoNotCall.MasterTableView.IsItemInserted = true;
//gvDoNotCall.MasterTableView.IsItemInserted = true;
FillGrid();
}
//else
//{
// var idx = int.Parse(e.CommandArgument.ToString());
// GridEditableItem item = gvDoNotCall.Items[idx];
// DoNotCallOjb dnc = new DoNotCallOjb();
// item.UpdateValues(dnc);
// AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
// gvDoNotCall.MasterTableView.IsItemInserted = true;
// //gvDoNotCall.MasterTableView.IsItemInserted = true;
// FillGrid();
//}
}
if (e.CommandName.Contains("CancelButton"))
{
if (e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
item.Edit = false;
gvDoNotCall.MasterTableView.Rebind();
}
}
}
protected void gvDoNotCall_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
DataSet dsDoNotCall = (DataSet)Session["gvDoNotCall_dtDoNotCall"];
if (dsDoNotCall != null)
{
gvDoNotCall.DataSource = dsDoNotCall;
}
}
public void FillGrid()
{
DataSet dsDoNotCall = AccountDAO.GetDoNotCall(Convert.ToInt32(Session["AccountId"]));
gvDoNotCall.DataSource = dsDoNotCall;
gvDoNotCall.DataBind();
Session["gvDoNotCall_dtDoNotCall"] = dsDoNotCall;
}
protected void gvDoNotCall_UpdateCommand(object sender, GridCommandEventArgs e)
{
var editableItem = ((GridEditableItem)e.Item);
var id = (int)editableItem.GetDataKeyValue("Id");
//int id = Convert.ToInt32(editableItem["Id"].Text);
DoNotCallOjb dnc = new DoNotCallOjb();
editableItem.UpdateValues(dnc);
log.Debug("Calling UpdateDoNotCall. Id = " + id + ", dnc.PhoneNumber = " + dnc.PhoneNumber);
DataSet dsDoNotCall = AccountDAO.GetDoNotCallByPhoneNumber(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber);
if (dsDoNotCall.Tables[0].Rows.Count == 0)
{
AccountDAO.UpdateDoNotCall(Convert.ToInt32(Session["AccountId"]), id, dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
FillGrid();
}
else
{
ErrorSummary.AddError("The number " + dnc.PhoneNumber + " is already in do not call list!", this);
return;
}
}
protected void gvDoNotCall_InsertCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item as GridEditableItem;
DoNotCallOjb dnc = new DoNotCallOjb();
item.UpdateValues(dnc);
DataSet dsDoNotCall = AccountDAO.GetDoNotCallByPhoneNumber(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber);
if (dsDoNotCall.Tables[0].Rows.Count == 0)
{
AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
//gvDoNotCall.MasterTableView.IsItemInserted = true;
FillGrid();
}
else
{
ErrorSummary.AddError("The number " + dnc.PhoneNumber + " is already in do not call list!", this);
return;
}
//gvDoNotCall.MasterTableView.Rebind();
//gvDoNotCall.Rebind();
}
protected void gvDoNotCall_DeleteCommand(object sender, GridCommandEventArgs e)
{
var editableItem = ((GridDataItem)e.Item);
var id = (int)editableItem.GetDataKeyValue("Id");
//int id = Convert.ToInt32(editableItem["Id"].Text);
AccountDAO.DeleteDoNotCall(Convert.ToInt32(Session["AccountId"]), id);
FillGrid();
}
protected void gvDoNotCall_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
TextBox tbPhone = (TextBox)item.FindControl("txtPhoneNumber");
tbPhone.Focus();
if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
{
LinkButton InsertButton = (LinkButton)e.Item.FindControl("PerformInsertButton");
InsertButton.CssClass = "action-button";
InsertButton.Visible = false;
LinkButton cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
cancelButton.CssClass = "action-button";
cancelButton.Visible = false;
Button SaveNewButton = (Button)e.Item.FindControl("btSaveNew");
SaveNewButton.Visible = true;
Button SaveCloseButton = (Button)e.Item.FindControl("btSaveClose");
SaveCloseButton.Visible = true;
Button CancelButton = (Button)e.Item.FindControl("btCancel");
CancelButton.Visible = true;
}
else
{
LinkButton UpdateButton = (LinkButton)e.Item.FindControl("UpdateButton");
UpdateButton.CssClass = "action-button";
//Page.Form.DefaultButton = UpdateButton.ClientID;
LinkButton cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
cancelButton.CssClass = "cancel-button";
}
}
}
protected void gvDoNotCall_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
TextBox tbPhone = (TextBox)item.FindControl("txtPhoneNumber");
if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
{
Button SaveNewButton = (Button)e.Item.FindControl("btSaveNew");
tbPhone.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + SaveNewButton.ClientID + "').click();return false;}} else {return true}; ");
}
else
{
LinkButton UpdateButton = (LinkButton)e.Item.FindControl("UpdateButton");
tbPhone.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + UpdateButton.ClientID + "').click();return false;}} else {return true}; ");
}
}
if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Table1")
{
GridDataItem item = (GridDataItem)e.Item;
GridTableCell PNumber = (GridTableCell)item["PrimaryNumber"];
GridTableCell SNumber = (GridTableCell)item["SecondaryNumber"];
GridTableCell cell = (GridTableCell)item["MatchedNumber"];
GridTableCell cell1 = (GridTableCell)item["MatchedBoth"];
if (cell1.Text == "1")
{
PNumber.CssClass = "strikethrough";
SNumber.CssClass = "strikethrough";
PNumber.ToolTip = "Number on Do Not Call list";
SNumber.ToolTip = "Number on Do Not Call list";
}
else
{
if (cell.Text == PNumber.Text)
{
PNumber.CssClass = "strikethrough";
PNumber.ToolTip = "Number on Do Not Call list";
}
else
{
SNumber.CssClass = "strikethrough";
SNumber.ToolTip = "Number on Do Not Call list";
}
}
}
}
protected void bnSearch_Click(object sender, EventArgs e)
{
string phoneNumber = txtSearchPhoneNumber.Text;
DataSet dsDoNotCall = AccountDAO.GetDoNotCallByPhoneNumber(Convert.ToInt32(Session["AccountId"]), phoneNumber);
gvDoNotCall.DataSource = dsDoNotCall;
gvDoNotCall.DataBind();
Session["gvDoNotCall_dtDoNotCall"] = dsDoNotCall;
}
protected void bnClearSearch_Click(object sender, EventArgs e)
{
DataSet dsDoNotCall = AccountDAO.GetDoNotCall(Convert.ToInt32(Session["AccountId"]));
gvDoNotCall.DataSource = dsDoNotCall;
gvDoNotCall.DataBind();
Session["gvDoNotCall_dtDoNotCall"] = dsDoNotCall;
txtSearchPhoneNumber.Text = string.Empty;
}
}
I am trying to export the values of the child of a RadGrid but it shows "No child records to display" when use gvDoNotCall.MasterTableView.HierarchyDefaultExpanded = true
I attached the code and an image of the grid
Thank you very much
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="DoNotCall.aspx.cs" Inherits="DoNotCall" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Import Namespace="Com.PromptAlert.PAPortalCommon" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<style type="text/css">
.strikethrough
{
text-decoration: line-through;
}
.rightalign
{
float:right;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
//We obtain the button we want to hit as default
$(document).keypress(function (e) {
var defaultButton = $("[id$=bnSearch]");
setEnterValue(e, defaultButton);
});
});
</script>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
args.get_eventTarget().indexOf("ExportToPdfButton") >= 0) {
args.set_enableAjax(false);
if (!confirm("You are exporting information potentially containing Protected Health Information (PHI) and/or Personally Identifiable Information (PII). Please click OK to proceed or Cancel to return to the previous screen")) { return false; }
}
}
</script>
</telerik:RadScriptBlock>
<h1 class="page-title">
Do Not Call List</h1>
<div class="box">
<%--<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">--%>
<div class="field-box" id="valSumm">
<asp:ValidationSummary CssClass="error-label" ID="valSummary" runat="server" HeaderText="The following errors occurred on the page: ">
</asp:ValidationSummary>
</div>
<div class="field-box">
<asp:Label CssClass="left-field" ID="lblSearchPhoneNumber" runat="server" Text="Search Phone Number:"></asp:Label>
<asp:TextBox CssClass="right-field" runat="server" ID="txtSearchPhoneNumber" ValidationGroup="vgroup2"></asp:TextBox>
<span>*
<asp:RegularExpressionValidator CssClass="error-label" ID="regexPhone1" runat="server" ValidationExpression="^(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$" ValidationGroup="vgroup2"
ControlToValidate="txtSearchPhoneNumber" ErrorMessage="Invalid Phone Format" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator CssClass="error-label" ID="rfPhone1" runat="server" ErrorMessage="Please enter a valid phone number" ValidationGroup="vgroup2"
ControlToValidate="txtSearchPhoneNumber" Display="Dynamic"></asp:RequiredFieldValidator>
</span>
</div>
<div class="field-box">
<asp:Button runat="server" Text="Search" CssClass="action-button left-field" value="Search" ID="bnSearch" ValidationGroup="vgroup2" OnClick="bnSearch_Click"/>
<asp:Button runat="server" Text="Clear Search" CssClass="action-button right-field" value="ClearSearch" ID="bnClearSearch" CausesValidation="false" OnClick="bnClearSearch_Click"/>
<asp:Label CssClass="rightalign" ID="Label1" runat="server" Text="Strike through phone number is <div style='display: inline-block;color:red;'>NOT</div> included in Do Not Call list"></asp:Label>
</div>
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" ClientEvents-OnRequestStart="onRequestStart">
<telerik:RadGrid ID="gvDoNotCall" runat="server" AllowFilteringByColumn="false" AllowPaging="True"
AllowSorting="True" CellSpacing="0" GridLines="None" PageSize="10" OnNeedDataSource="gvDoNotCall_NeedDataSource"
AutoGenerateColumns="false" OnItemCommand="gvDoNotCall_ItemCommand" OnDeleteCommand="gvDoNotCall_DeleteCommand" OnItemDataBound="gvDoNotCall_ItemDataBound"
OnInsertCommand="gvDoNotCall_InsertCommand" OnUpdateCommand="gvDoNotCall_UpdateCommand" OnItemCreated="gvDoNotCall_ItemCreated" AutoGenerateHierarchy="true"
OnPageIndexChanging="gvDoNotCall_PageIndexChanging">
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<DetailTables>
<telerik:GridTableView Name="tblClients" DataKeyNames="HomePhone"
Width="100%" NoDetailRecordsText="No Client for this number"
AllowFilteringByColumn="false" AllowPaging="false">
<Columns>
<telerik:GridBoundColumn UniqueName="ClientRecordNumber" HeaderText="MRN" DataField="ClientRecordNumber" />
<telerik:GridBoundColumn UniqueName="FirstName" HeaderText="Client First Name"
DataField="FirstName" />
<telerik:GridBoundColumn UniqueName="LastName" HeaderText="Client Last Name"
DataField="LastName" />
<telerik:GridDateTimeColumn UniqueName="DateOfBirth" HeaderText="Date Of Birth" DataField="DateOfBirth"
AllowFiltering="false" DataFormatString="{0:dd MMM yyyy}" />
<telerik:GridBoundColumn UniqueName="PrimaryNumber" HeaderText="Primary Number"
DataField="PrimaryNumber" />
<telerik:GridBoundColumn UniqueName="SecondaryNumber" HeaderText="Secondary Number"
DataField="SecondaryNumber" />
<telerik:GridBoundColumn UniqueName="MatchedNumber" HeaderText="Matched Number" Display="false"
DataField="MatchedNumber" />
<telerik:GridBoundColumn UniqueName="MatchedBoth" HeaderText="Matched Both" Display="false"
DataField="MatchedBoth" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridButtonColumn UniqueName="EditButtonId" ButtonCssClass="edit-button" ButtonType="ImageButton" CommandName="Edit" HeaderText="Edit" ImageUrl="../App_Themes/Modern/images/edit-button.png" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"/>
<telerik:GridButtonColumn UniqueName="DeleteButtonId" ButtonCssClass="delete-button" HeaderText="Delete" ConfirmText="Delete this do not call entry?" ConfirmDialogType="Classic" HeaderStyle-HorizontalAlign="Center"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"
ConfirmDialogWidth="220px" ImageUrl="../App_Themes/Modern/images/delete-button.png" HeaderStyle-Width="100px" />
<telerik:GridBoundColumn UniqueName="Id" HeaderText="Id" DataField="Id" ReadOnly="true"
Visible="false" />
<telerik:GridTemplateColumn UniqueName="PhoneNumber" HeaderText="Phone Number" DataField="PhoneNumber">
<ItemTemplate>
<asp:Label runat="server" ID="lblPhoneNumber" Text='<%# Eval("PhoneNumber") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtPhoneNumber" Text='<%# Bind("PhoneNumber") %>' ValidationGroup="vgroup1"></asp:TextBox>
<span>*
<asp:RegularExpressionValidator CssClass="error-label" ID="regexPhone2" runat="server" ValidationExpression="^(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$" ValidationGroup="vgroup1"
ControlToValidate="txtPhoneNumber" ErrorMessage="Invalid Phone Format" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator CssClass="error-label" ID="rfPhone2" runat="server" ErrorMessage="Please enter a valid phone number" ValidationGroup="vgroup1"
ControlToValidate="txtPhoneNumber" Display="Dynamic"></asp:RequiredFieldValidator>
</span>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="LastUpdatedBy" HeaderText="Last Updated By"
DataField="LastUpdatedUserId">
<ItemTemplate>
<asp:Label runat="server" ID="LastUpdatedUserId" Text='<%# Utility.GetUserNameByIdStaff(Convert.ToInt32(Eval("LastUpdatedUserId"))) %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn UniqueName="LastUpdatedDateTime" HeaderText="Last Updated Date"
DataField="LastUpdatedDateTime" ReadOnly="true" />
<telerik:GridTemplateColumn UniqueName="InsertButton" HeaderText="">
<EditItemTemplate>
<%--<asp:TextBox runat="server" ID="txtPhoneNumber" Text='<%# Bind("PhoneNumber") %>'></asp:TextBox>--%>
<asp:Button ID="btSaveNew" runat="server" CssClass="action-button" Text="Save and New" CommandName="SaveNew" Visible="false" ValidationGroup="vgroup1"></asp:Button>
<asp:Button ID="btSaveClose" runat="server" CssClass="action-button" Text="Save and Close" CommandName="SaveClose" Visible="false" ValidationGroup="vgroup1"></asp:Button>
<asp:Button ID="btCancel" runat="server" CssClass="action-button" Text="Cancel" CommandName="CancelButton" Visible="false" CausesValidation="false"></asp:Button>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<CommandItemSettings ShowExportToExcelButton="true" ShowExportToWordButton="true"
ShowExportToPdfButton="true" ShowAddNewRecordButton="true" ShowRefreshButton="true" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
<Excel Format="Html" />
</ExportSettings>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
<ValidationSettings CommandsToValidate="PerformInsert,Update" />
</telerik:RadGrid>
</telerik:RadAjaxPanel>
<telerik:RadWindowManager runat="server" ID="RadWindowManager1" Title="PatientPrompt.com"
InitialBehaviors="Default" KeepInScreenBounds="true">
</telerik:RadWindowManager>
<%--<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />--%>
</div>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
// logging imports
using log4net;
using log4net.Appender;
using log4net.Config;
using Telerik.Web.UI;
using Com.PromptAlert.PAPortalCommon.Dao;
using Com.PromptAlert.PAPortalCommon;
using Com.PromptAlert.PAPortalCommon.Domain;
using DoNotCallOjb = Com.PromptAlert.Domain.DoNotCall;
public partial class DoNotCall : System.Web.UI.Page
{
// define loggers
public static readonly ILog log = LogManager.GetLogger("Account_DoNotCall.aspx.cs");
private bool isExport = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillGrid();
}
//LinkButton UpdateButton = (LinkButton)e.Item.FindControl("UpdateButton");
txtSearchPhoneNumber.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + bnSearch.ClientID + "').click();return false;}} else {return true}; ");
}
protected void gvDoNotCall_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName.Contains("Export"))
{
isExport = true;
gvDoNotCall.MasterTableView.GetColumn("EditButtonId").Visible = false;
gvDoNotCall.MasterTableView.GetColumn("DeleteButtonId").Visible = false;
// gvDoNotCall.MasterTableView.HierarchyDefaultExpanded = true;
}
if (e.CommandName.Contains("SaveClose"))
{
if (e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
DoNotCallOjb dnc = new DoNotCallOjb();
item.UpdateValues(dnc);
AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
//gvDoNotCall.MasterTableView.IsItemInserted = true;
//FillGrid();
Response.Redirect("~/dashboard");
}
}
if (e.CommandName.Contains("SaveNew"))
{
if (e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
DoNotCallOjb dnc = new DoNotCallOjb();
item.UpdateValues(dnc);
AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
gvDoNotCall.MasterTableView.IsItemInserted = true;
//gvDoNotCall.MasterTableView.IsItemInserted = true;
FillGrid();
}
//else
//{
// var idx = int.Parse(e.CommandArgument.ToString());
// GridEditableItem item = gvDoNotCall.Items[idx];
// DoNotCallOjb dnc = new DoNotCallOjb();
// item.UpdateValues(dnc);
// AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
// gvDoNotCall.MasterTableView.IsItemInserted = true;
// //gvDoNotCall.MasterTableView.IsItemInserted = true;
// FillGrid();
//}
}
if (e.CommandName.Contains("CancelButton"))
{
if (e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
item.Edit = false;
gvDoNotCall.MasterTableView.Rebind();
}
}
}
protected void gvDoNotCall_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
DataSet dsDoNotCall = (DataSet)Session["gvDoNotCall_dtDoNotCall"];
if (dsDoNotCall != null)
{
gvDoNotCall.DataSource = dsDoNotCall;
}
}
public void FillGrid()
{
DataSet dsDoNotCall = AccountDAO.GetDoNotCall(Convert.ToInt32(Session["AccountId"]));
gvDoNotCall.DataSource = dsDoNotCall;
gvDoNotCall.DataBind();
Session["gvDoNotCall_dtDoNotCall"] = dsDoNotCall;
}
protected void gvDoNotCall_UpdateCommand(object sender, GridCommandEventArgs e)
{
var editableItem = ((GridEditableItem)e.Item);
var id = (int)editableItem.GetDataKeyValue("Id");
//int id = Convert.ToInt32(editableItem["Id"].Text);
DoNotCallOjb dnc = new DoNotCallOjb();
editableItem.UpdateValues(dnc);
log.Debug("Calling UpdateDoNotCall. Id = " + id + ", dnc.PhoneNumber = " + dnc.PhoneNumber);
DataSet dsDoNotCall = AccountDAO.GetDoNotCallByPhoneNumber(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber);
if (dsDoNotCall.Tables[0].Rows.Count == 0)
{
AccountDAO.UpdateDoNotCall(Convert.ToInt32(Session["AccountId"]), id, dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
FillGrid();
}
else
{
ErrorSummary.AddError("The number " + dnc.PhoneNumber + " is already in do not call list!", this);
return;
}
}
protected void gvDoNotCall_InsertCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item as GridEditableItem;
DoNotCallOjb dnc = new DoNotCallOjb();
item.UpdateValues(dnc);
DataSet dsDoNotCall = AccountDAO.GetDoNotCallByPhoneNumber(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber);
if (dsDoNotCall.Tables[0].Rows.Count == 0)
{
AccountDAO.AddDoNotCall(Convert.ToInt32(Session["AccountId"]), dnc.PhoneNumber, Convert.ToInt32(Session["PortalUserId"]));
//gvDoNotCall.MasterTableView.IsItemInserted = true;
FillGrid();
}
else
{
ErrorSummary.AddError("The number " + dnc.PhoneNumber + " is already in do not call list!", this);
return;
}
//gvDoNotCall.MasterTableView.Rebind();
//gvDoNotCall.Rebind();
}
protected void gvDoNotCall_DeleteCommand(object sender, GridCommandEventArgs e)
{
var editableItem = ((GridDataItem)e.Item);
var id = (int)editableItem.GetDataKeyValue("Id");
//int id = Convert.ToInt32(editableItem["Id"].Text);
AccountDAO.DeleteDoNotCall(Convert.ToInt32(Session["AccountId"]), id);
FillGrid();
}
protected void gvDoNotCall_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
TextBox tbPhone = (TextBox)item.FindControl("txtPhoneNumber");
tbPhone.Focus();
if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
{
LinkButton InsertButton = (LinkButton)e.Item.FindControl("PerformInsertButton");
InsertButton.CssClass = "action-button";
InsertButton.Visible = false;
LinkButton cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
cancelButton.CssClass = "action-button";
cancelButton.Visible = false;
Button SaveNewButton = (Button)e.Item.FindControl("btSaveNew");
SaveNewButton.Visible = true;
Button SaveCloseButton = (Button)e.Item.FindControl("btSaveClose");
SaveCloseButton.Visible = true;
Button CancelButton = (Button)e.Item.FindControl("btCancel");
CancelButton.Visible = true;
}
else
{
LinkButton UpdateButton = (LinkButton)e.Item.FindControl("UpdateButton");
UpdateButton.CssClass = "action-button";
//Page.Form.DefaultButton = UpdateButton.ClientID;
LinkButton cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
cancelButton.CssClass = "cancel-button";
}
}
}
protected void gvDoNotCall_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
TextBox tbPhone = (TextBox)item.FindControl("txtPhoneNumber");
if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
{
Button SaveNewButton = (Button)e.Item.FindControl("btSaveNew");
tbPhone.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + SaveNewButton.ClientID + "').click();return false;}} else {return true}; ");
}
else
{
LinkButton UpdateButton = (LinkButton)e.Item.FindControl("UpdateButton");
tbPhone.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + UpdateButton.ClientID + "').click();return false;}} else {return true}; ");
}
}
if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Table1")
{
GridDataItem item = (GridDataItem)e.Item;
GridTableCell PNumber = (GridTableCell)item["PrimaryNumber"];
GridTableCell SNumber = (GridTableCell)item["SecondaryNumber"];
GridTableCell cell = (GridTableCell)item["MatchedNumber"];
GridTableCell cell1 = (GridTableCell)item["MatchedBoth"];
if (cell1.Text == "1")
{
PNumber.CssClass = "strikethrough";
SNumber.CssClass = "strikethrough";
PNumber.ToolTip = "Number on Do Not Call list";
SNumber.ToolTip = "Number on Do Not Call list";
}
else
{
if (cell.Text == PNumber.Text)
{
PNumber.CssClass = "strikethrough";
PNumber.ToolTip = "Number on Do Not Call list";
}
else
{
SNumber.CssClass = "strikethrough";
SNumber.ToolTip = "Number on Do Not Call list";
}
}
}
}
protected void bnSearch_Click(object sender, EventArgs e)
{
string phoneNumber = txtSearchPhoneNumber.Text;
DataSet dsDoNotCall = AccountDAO.GetDoNotCallByPhoneNumber(Convert.ToInt32(Session["AccountId"]), phoneNumber);
gvDoNotCall.DataSource = dsDoNotCall;
gvDoNotCall.DataBind();
Session["gvDoNotCall_dtDoNotCall"] = dsDoNotCall;
}
protected void bnClearSearch_Click(object sender, EventArgs e)
{
DataSet dsDoNotCall = AccountDAO.GetDoNotCall(Convert.ToInt32(Session["AccountId"]));
gvDoNotCall.DataSource = dsDoNotCall;
gvDoNotCall.DataBind();
Session["gvDoNotCall_dtDoNotCall"] = dsDoNotCall;
txtSearchPhoneNumber.Text = string.Empty;
}
}