Hi,
I am using radgrid to display data, I am adding columns programatically when page loads the header text is showing, but when i clicking on column header for sorting, the header text is missing and when i click on next page header text shown again and again hide on clicking for sorting.
Here is the my aspx page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewingExtendedRegistration.aspx.cs"
Inherits="IntegratedSystem.VendorUserReport.ViewingExtendedRegistration" %>
<%@ Register Src="../UC/Top.ascx" TagName="Top" TagPrefix="uc1" %>
<%@ Register Src="Control/DateFilter.ascx" TagName="Datefilter" TagPrefix="uc1" %>
<%@ Register Src="Control/TimeFrame.ascx" TagName="TimeFrame" TagPrefix="uc1" %>
<%@ Register Src="Control/ShowAll.ascx" TagName="ShowAll" TagPrefix="uc1" %>
<%@ Register Src="Control/StatusFilter.ascx" TagName="Status" TagPrefix="uc1" %>
<%@ Register Src="Control/EventFilter.ascx" TagName="EventFilter" TagPrefix="uc1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Extended Registration Data</title>
<script src="Js/Config.js" type="text/javascript"></script>
<script src="Js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.dataTables.min.js" type="text/javascript"></script>
<link href="Styles/demo_table_jui.css" rel="stylesheet" type="text/css" />
<link href="Styles/JqueryUi.css" rel="stylesheet" type="text/css" />
<script src="js/JqueryUi.js" type="text/javascript"></script>
<script src="js/jquery.dataTables1.js" type="text/javascript"></script>
<link href="Styles/style2.css" rel="stylesheet" type="text/css" />
<link href="Styles/VideoDetailUI.css" rel="stylesheet" type="text/css" />
<link href="Styles/chosen.min.css" rel="stylesheet" type="text/css" />
<script src="Js/chosen.jquery.min.js" type="text/javascript"></script>
<script src="Js/Common.js" type="text/javascript"></script>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportMasterDataButton") > 0) {
args.set_enableAjax(false);
}
}
function setStartAndEndDate(startDate, endDate) {
document.getElementById("hdnStartDate").value = startDate;
document.getElementById("hdnEndDate").value = endDate;
}
function fnFilterByStatus(selVal) {
document.getElementById("hdnStatus").value = selVal;
}
function fnFilterByEvent(selVal) {
document.getElementById("hdnEvent").value = selva;
}
</script>
</telerik:RadCodeBlock>
<style type="text/css">
.ui-dialog-titlebar-close
{
visibility: hidden;
}
div.dataTables_wrapper
{
width: 1000px;
}
th
{
cursor: pointer;
background-color: #dadada;
color: Black;
font-weight: bold;
text-align: left;
width: auto;
}
th.headerSortUp
{
background-image: url(Scripts/asc.gif);
background-position: right center;
background-repeat: no-repeat;
}
th.headerSortDown
{
background-image: url(Scripts/desc.gif);
background-position: right center;
background-repeat: no-repeat;
}
.dataTables_wrapper .ui-toolbar
{
padding: 0px;
}
#ExportMasterDataButton
{
border: 0;
width: 129px;
height: 31px;
background: url('Images/Export-excel-1.png') no-repeat;
cursor: pointer;
}
</style>
</head>
<body>
<uc1:Top ID="Top1" runat="server" />
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<div class="navigation-main">
<div class="navigation">
<ul>
<li><a href="#" style="background: none repeat scroll 0 0 #1FBBA6; color: #FFFFFF;
cursor: default; text-shadow: 1px 1px 1px #474A4D; border-radius: 5px 5px 0 0;
display: block; margin-right: 5px; padding: 10px 20px 7px; text-decoration: none;
width: auto;">Extended Registration Data</a></li>
</ul>
</div>
</div>
<div class="choose-video-header">
<div class="choose-video-inner">
<div class="choose-text">
Extended Registration Data Report
</div>
<div class="choose-text-child">
</div>
</div>
</div>
<div class="main-body" style="width: 1000px">
<uc1:TimeFrame ID="TimeFrame1" runat="server" />
<%--<% if (parentcompany_id != 2840 && parentcompany_id == 2960)
{ %>
<div class="Drop-down-div" style="clear:both" >
<div style="margin-top: 5px; clear:both; width: 74px" class="Drop-down-child">Other Filter </div>
<div class="Drop-down-child">
<uc1:EventFilter ID="EventFilter1" runat="server" />
</div>
<div class="Drop-down-child">
<uc1:Status ID="Status1" runat="server" />
</div>
</div>
<%} %>--%>
<div class="Drop-down-div">
<span style=" padding-left:140px">
<uc1:ShowAll ID="ShowAll1" runat="server" />
</span>
</div>
<div class="message"><asp:Literal ID="ltMessage" Visible="false" runat="server" Text="No viewings are available"></asp:Literal></div>
<div style=" width:1000px; overflow-x:auto; margin:auto">
<telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" AutoGenerateColumns="false" PageSize="100"
AllowPaging="true" OnDataBound="RadGrid1_OnDataBound" OnSortCommand="RadGrid1_OnSortCommand"
AllowSorting="true" AllowCustomPaging="true" OnItemCommand="RadGrid1_OnItemCommand"
CellSpacing="1" Style="padding: 1px;" Skin="Default" OnNeedDataSource="RadGrid1_OnNeedDataSource"
OnExportCellFormatting="RadGrid1_ExportCellFormatting" OnHTMLExporting="RadGrid1_OnHtmlExporting">
<ItemStyle Wrap="false"></ItemStyle>
<ClientSettings>
<Selecting AllowRowSelect="False" />
<Scrolling AllowScroll="true" ScrollHeight="500px" />
</ClientSettings>
<ExportSettings Excel-Format="Html" ExportOnlyData="true" IgnorePaging="true" UseItemStyles="true"
OpenInNewWindow="true">
</ExportSettings>
<MasterTableView Name="ViewingDataForUsers" CommandItemDisplay="Top" TableLayout="Fixed">
<HeaderStyle Font-Size="14px" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True" />
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" />
<CommandItemTemplate>
<asp:Button ID="ExportMasterDataButton" runat="server" CommandName="ExportMasterData"
ClientIDMode="Static"></asp:Button>
</CommandItemTemplate>
</MasterTableView>
<FilterMenu EnableImageSprites="False" />
<PagerStyle PageSizeControlType="RadDropDownList" />
</telerik:RadGrid>
</div>
<div class="clear">
</div>
</div>
<div id="overlay" class="web_dialog_overlay"></div>
<uc1:Datefilter ID="DFilter" runat="server" />
<input type="hidden" id="hdnStartDate" runat="server" />
<input type="hidden" id="hdnEndDate" runat="server" />
<input type="hidden" id="hdnEvent" runat="server" value="-1" />
<input type="hidden" id="hdnStatus" runat="server" value="-1" />
</form>
</body>
</html>
and code in aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IntegratedSystem.VendorUserReport.Objects;
using Telerik.Web.UI;
namespace IntegratedSystem.VendorUserReport
{
public partial class ViewingExtendedRegistration : System.Web.UI.Page
{
public string Message = string.Empty;
public int parentcompany_id = 0;
protected int Userid = 0;
protected int UserLevel = 0;
private int event_Id = 0;
private int regStatus_Id = 0;
protected string NameSpace = string.Empty;
public string DateStart = DateTime.Now.Date.AddDays(-Int32.Parse("30")).ToShortDateString();
protected string EndDate = "01/01/2040";
protected int virtualItemCount = 0;
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.TimeFrame1.ddlCount_Change_Event += new Control.TimeFrame.FiltereByddlCount(this.ddlCount_Change_Event);
this.DFilter.DateFilter_Search_Click += new Control.DateFilter.FilterByDateRange(this.DateFilter_Search_Click);
this.TimeFrame1.ddlWeek_Change_Event += new Control.TimeFrame.FiltereByIndex(this.ddlWeeks_Change_Event);
this.ShowAll1.ShowAll_Click += new Control.ShowAll.ShowAllList(this.ShowAll1_ShowAll_Click);
}
protected void Page_Load(object sender, EventArgs e)
{
HttpCookieCollection MyCookieCollection = new HttpCookieCollection();
MyCookieCollection = Request.Cookies;
HttpCookie myCookie = MyCookieCollection.Get("ClientUser");
if (!string.IsNullOrEmpty(myCookie["UID"]) && !string.IsNullOrEmpty(myCookie["PC"]))
{
if (myCookie["PC"] != "")
{
parentcompany_id = Int32.Parse(myCookie["PC"]);
Userid = Int32.Parse(myCookie["UID"]);
UserLevel = Int32.Parse(myCookie["UL"]);
NameSpace = myCookie["PCNS"].ToString();
}
if (myCookie["RUID"] != "")
{
Userid = Int32.Parse(myCookie["RUID"]);
parentcompany_id = 5250;
NameSpace = "DODS_Main";
}
AddColumnsInRadGrid();
}
else
{
Server.Transfer("../SSBT/error.aspx");
}
}
protected DataTable GetData(string startDate, string endDate, string sortBy, string sortDirection, int pageNum, int pageSize)
{
return ViewingHelper.ViewingByExtendedRegistrationList(this.parentcompany_id, this.Userid, this.UserLevel, startDate ?? DateStart, endDate ?? EndDate,
sortBy, sortDirection, pageNum, pageSize,Convert.ToInt32( hdnEvent.Value), Convert.ToInt32(hdnStatus.Value), ref virtualItemCount, ref Message);
}
protected void DateFilter_Search_Click()
{
this.DateStart = this.DFilter.GetStartDate();
this.EndDate = this.DFilter.GetEndDate();
//BindGrid(parentcompany_id, Userid, UserLevel, DateStart, EndDate, event_Id, regStatus_Id, ref Message);
}
protected void ddlWeeks_Change_Event()
{
this.DateStart = this.TimeFrame1.SelectedDateRange;
//BindGrid(parentcompany_id, Userid, UserLevel, DateStart, EndDate, event_Id, regStatus_Id, ref Message);
}
protected void ddlCount_Change_Event()
{
this.DateStart = this.TimeFrame1.SelectedDateRange;
//BindGrid(parentcompany_id, Userid, UserLevel, DateStart, EndDate, event_Id, regStatus_Id, ref Message);
}
protected void ShowAll1_ShowAll_Click()
{
ViewState["DateStart"] = hdnStartDate.Value;
ViewState["EndDate"] = hdnEndDate.Value;
RadGrid1.Rebind();
}
private void AddColumnsInRadGrid()
{
RadGrid1.Columns.Clear();
if (parentcompany_id == 2840)
{
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "Registration Date";
col1.DataField = "Registration_Date";
col1.SortExpression = "";
col1.DataFormatString = "{0:d}";
col1.ItemStyle.Width = 100;
RadGrid1.Columns.Add(col1);
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "Traffic Source";
col2.DataField = "Promo_Code";
col2.SortExpression = "Promo_Code";
RadGrid1.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
col3.HeaderText = "Last Name";
col3.DataField = "Last_Name";
col3.SortExpression = "Last_Name";
RadGrid1.Columns.Add(col3);
GridBoundColumn col4 = new GridBoundColumn();
col4.HeaderText = "First Name";
col4.DataField = "First_Name";
col4.SortExpression = "First_Name";
RadGrid1.Columns.Add(col4);
GridBoundColumn col5 = new GridBoundColumn();
col5.HeaderText = "Company Name";
col5.DataField = "Company_Name";
col5.ItemStyle.Width = 100;
col5.SortExpression = "Company_Name";
RadGrid1.Columns.Add(col5);
GridBoundColumn col6 = new GridBoundColumn();
col6.HeaderText = "Address Line 1";
col6.DataField = "Address_Line_1";
col6.SortExpression = "Address_Line_1";
RadGrid1.Columns.Add(col6);
GridBoundColumn col7 = new GridBoundColumn();
col7.HeaderText = "Address Line 2";
col7.DataField = "Address_Line_2";
col7.SortExpression = "Address_Line_2";
RadGrid1.Columns.Add(col7);
GridBoundColumn col8 = new GridBoundColumn();
col8.HeaderText = "City";
col8.DataField = "city";
col8.SortExpression = "city";
RadGrid1.Columns.Add(col8);
GridBoundColumn col9 = new GridBoundColumn();
col9.HeaderText = "State";
col9.DataField = "state";
col9.SortExpression = "state";
RadGrid1.Columns.Add(col9);
GridBoundColumn col10 = new GridBoundColumn();
col10.HeaderText = "Zip/Postal Code";
col10.DataField = "Postal_Code";
col10.SortExpression = "Postal_Code";
RadGrid1.Columns.Add(col10);
GridBoundColumn col11 = new GridBoundColumn();
col11.HeaderText = "Country";
col11.DataField = "CountryName";
col11.SortExpression = "CountryName";
RadGrid1.Columns.Add(col11);
GridBoundColumn col12 = new GridBoundColumn();
col12.HeaderText = "Phone";
col12.DataField = "Phone";
col12.SortExpression = "Phone";
RadGrid1.Columns.Add(col12);
GridBoundColumn col13 = new GridBoundColumn();
col13.HeaderText = "Email Address";
col13.DataField = "Email_Address";
col13.SortExpression = "Email_Address";
RadGrid1.Columns.Add(col13);
GridBoundColumn col14 = new GridBoundColumn();
col14.HeaderText = "Title";
col14.DataField = "Title";
col14.SortExpression = "Title";
RadGrid1.Columns.Add(col14);
}
else
{
if (parentcompany_id == 2960)
{
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "Registration Date";
col1.DataField = "Registration_Date";
col1.DataFormatString = "{0:d}";
col1.SortExpression = "Registration_Date";
RadGrid1.Columns.Add(col1);
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "Traffic Source";
col2.DataField = "Promo_Code";
col2.SortExpression = "Promo_Code";
RadGrid1.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
col3.HeaderText = "Last Name";
col3.DataField = "Last_Name";
col3.SortExpression = "Last_Name";
RadGrid1.Columns.Add(col3);
GridBoundColumn col4 = new GridBoundColumn();
col4.HeaderText = "First Name";
col4.DataField = "First_Name";
col4.SortExpression = "First_Name";
RadGrid1.Columns.Add(col4);
GridBoundColumn col5 = new GridBoundColumn();
col5.HeaderText = "Email Address";
col5.DataField = "Email_Address";
col5.SortExpression = "Email_Address";
RadGrid1.Columns.Add(col5);
GridBoundColumn col6 = new GridBoundColumn();
col6.HeaderText = "Company Name";
col6.DataField = "Company_Name";
col6.ItemStyle.Width = 100;
col6.SortExpression = "Company_Name";
RadGrid1.Columns.Add(col6);
GridBoundColumn col8 = new GridBoundColumn();
col8.HeaderText = "City";
col8.DataField = "city";
col8.SortExpression = "city";
RadGrid1.Columns.Add(col8);
GridBoundColumn col9 = new GridBoundColumn();
col9.HeaderText = "State";
col9.DataField = "state";
col9.SortExpression = "state";
RadGrid1.Columns.Add(col9);
GridBoundColumn col10 = new GridBoundColumn();
col10.HeaderText = "Zip/Postal Code";
col10.DataField = "Postal_Code";
col10.SortExpression = "Postal_Code";
RadGrid1.Columns.Add(col10);
GridBoundColumn col11 = new GridBoundColumn();
col11.HeaderText = "Country";
col11.DataField = "CountryCode";
col11.SortExpression = "CountryCode";
RadGrid1.Columns.Add(col11);
GridBoundColumn col12 = new GridBoundColumn();
col12.HeaderText = "Phone";
col12.DataField = "Phone";
col12.SortExpression = "Phone";
RadGrid1.Columns.Add(col12);
}
else
{
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "Registration Date";
col1.DataField = "Registration_Date";
col1.DataFormatString = "{0:d}";
col1.ItemStyle.Width = 100;
col1.SortExpression = "Registration_Date";
RadGrid1.Columns.Add(col1);
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "Event Name";
col2.DataField = "Event_Name";
col2.SortExpression = "Event_Name";
RadGrid1.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
col3.HeaderText = "Registration Status";
col3.DataField = "Registration_Status";
col3.SortExpression = "Registration_Status";
RadGrid1.Columns.Add(col3);
GridBoundColumn col4 = new GridBoundColumn();
col4.HeaderText = "First Name";
col4.DataField = "First_Name";
col4.SortExpression = "First_Name";
RadGrid1.Columns.Add(col4);
GridBoundColumn col41 = new GridBoundColumn();
col41.HeaderText = "Last Name";
col41.DataField = "Last_Name";
col41.SortExpression = "Last_Name";
RadGrid1.Columns.Add(col41);
GridBoundColumn col5 = new GridBoundColumn();
col5.HeaderText = "Email Address";
col5.DataField = "Email_Address";
col5.SortExpression = "Email_Address";
RadGrid1.Columns.Add(col5);
GridBoundColumn col6 = new GridBoundColumn();
col6.HeaderText = "Phone";
col6.DataField = "Phone";
col6.SortExpression = "Phone";
RadGrid1.Columns.Add(col6);
GridBoundColumn col7 = new GridBoundColumn();
col7.HeaderText = "Address Line 1";
col7.DataField = "Address_Line_1";
col7.SortExpression = "Address_Line_1";
RadGrid1.Columns.Add(col7);
GridBoundColumn col8 = new GridBoundColumn();
col8.HeaderText = "City";
col8.DataField = "city";
col8.SortExpression = "city";
RadGrid1.Columns.Add(col8);
GridBoundColumn col9 = new GridBoundColumn();
col9.HeaderText = "State";
col9.DataField = "state";
col9.SortExpression = "state";
RadGrid1.Columns.Add(col9);
GridBoundColumn col10 = new GridBoundColumn();
col10.HeaderText = "Zip/Postal Code";
col10.DataField = "Postal_Code";
col10.SortExpression = "Postal_Code";
RadGrid1.Columns.Add(col10);
GridBoundColumn col11 = new GridBoundColumn();
col11.HeaderText = "Country";
col11.DataField = "CountryName";
col11.SortExpression = "CountryName";
RadGrid1.Columns.Add(col11);
GridBoundColumn col12 = new GridBoundColumn();
col12.HeaderText = "Title";
col12.DataField = "Title";
col12.SortExpression = "Title";
RadGrid1.Columns.Add(col12);
GridBoundColumn col13 = new GridBoundColumn();
col13.HeaderText = "Company Name";
col13.DataField = "Company_Name";
col13.ItemStyle.Width = 100;
col13.SortExpression = "Company_Name";
RadGrid1.Columns.Add(col13);
}
}
}
protected void RadGrid1_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
int startRowIndex = HasRecords() ? RadGrid1.CurrentPageIndex + 1 : 1;
string startDate = !IsPostBack ? DateStart : (string)ViewState["DateStart"];
string endDate = !IsPostBack ? EndDate : (string)ViewState["EndDate"];
string sortBy = (string)ViewState["SortBy"];
string sortDirection = (string)ViewState["SortDirection"];
RadGrid1.DataSource = GetData(startDate, endDate, sortBy, sortDirection, startRowIndex, RadGrid1.PageSize);
RadGrid1.VirtualItemCount = virtualItemCount;
}
protected void RadGrid1_OnSortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)
{
//e.Canceled = true;
if ((string)ViewState["SortBy"] != e.SortExpression)
{
ViewState["SortDirection"] = "desc";
}
ViewState["SortBy"] = e.SortExpression;
string startDate = !IsPostBack ? DateStart : (string)ViewState["DateStart"];
string endDate = !IsPostBack ? EndDate : (string)ViewState["EndDate"];
ViewState["SortExpression"] = e.SortExpression;
RadGrid1.DataSource = GetData(startDate, endDate, (string)ViewState["SortExpression"], (string)ViewState["SortDirection"],
this.RadGrid1.CurrentPageIndex + 1, this.RadGrid1.PageSize);
RadGrid1.VirtualItemCount = virtualItemCount;
RadGrid1.DataBind();
if ((string)ViewState["SortDirection"] == "desc")
{
ViewState["SortDirection"] = "asc";
}
else
{
ViewState["SortDirection"] = "desc";
}
}
private bool HasRecords()
{
return RadGrid1.MasterTableView.Items.Count > 0;
}
protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "ExportMasterData")
{
RadGrid1.ExportSettings.FileName = "ExtendedRegistrationViewingReport";
RadGrid1.PageSize = RadGrid1.MasterTableView.PageSize;
RadGrid1.MasterTableView.ExportToExcel();
}
}
protected void RadGrid1_OnHtmlExporting(object sender, GridHTMLExportingEventArgs e)
{
e.Styles.Append("body { border:solid 0.1pt #CCCCCC; }");
e.Styles.Append("br { mso-data-placement: same-cell; }");
}
protected void RadGrid1_OnDataBound(object sender, EventArgs e)
{
if (RadGrid1.Items.Count == 0)
{
RadGrid1.Visible = false;
ltMessage.Visible = true;
ClientScript.RegisterStartupScript(this.GetType(), "IsNotAvailable", "IsNotAvailable();", true);
}
else
{
RadGrid1.Visible = true;
ltMessage.Visible = true;
ltMessage.Text = Message;
}
}
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
GridDataItem item = e.Cell.Parent as GridDataItem;
if (item == null)
{
return;
}
item.Style["text-align"] = "left";
}
}
}
Please let me know what i am doing wrong or missing something
Any help will be great
Thanks & Regards
Bharat
I am using radgrid to display data, I am adding columns programatically when page loads the header text is showing, but when i clicking on column header for sorting, the header text is missing and when i click on next page header text shown again and again hide on clicking for sorting.
Here is the my aspx page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewingExtendedRegistration.aspx.cs"
Inherits="IntegratedSystem.VendorUserReport.ViewingExtendedRegistration" %>
<%@ Register Src="../UC/Top.ascx" TagName="Top" TagPrefix="uc1" %>
<%@ Register Src="Control/DateFilter.ascx" TagName="Datefilter" TagPrefix="uc1" %>
<%@ Register Src="Control/TimeFrame.ascx" TagName="TimeFrame" TagPrefix="uc1" %>
<%@ Register Src="Control/ShowAll.ascx" TagName="ShowAll" TagPrefix="uc1" %>
<%@ Register Src="Control/StatusFilter.ascx" TagName="Status" TagPrefix="uc1" %>
<%@ Register Src="Control/EventFilter.ascx" TagName="EventFilter" TagPrefix="uc1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Extended Registration Data</title>
<script src="Js/Config.js" type="text/javascript"></script>
<script src="Js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.dataTables.min.js" type="text/javascript"></script>
<link href="Styles/demo_table_jui.css" rel="stylesheet" type="text/css" />
<link href="Styles/JqueryUi.css" rel="stylesheet" type="text/css" />
<script src="js/JqueryUi.js" type="text/javascript"></script>
<script src="js/jquery.dataTables1.js" type="text/javascript"></script>
<link href="Styles/style2.css" rel="stylesheet" type="text/css" />
<link href="Styles/VideoDetailUI.css" rel="stylesheet" type="text/css" />
<link href="Styles/chosen.min.css" rel="stylesheet" type="text/css" />
<script src="Js/chosen.jquery.min.js" type="text/javascript"></script>
<script src="Js/Common.js" type="text/javascript"></script>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportMasterDataButton") > 0) {
args.set_enableAjax(false);
}
}
function setStartAndEndDate(startDate, endDate) {
document.getElementById("hdnStartDate").value = startDate;
document.getElementById("hdnEndDate").value = endDate;
}
function fnFilterByStatus(selVal) {
document.getElementById("hdnStatus").value = selVal;
}
function fnFilterByEvent(selVal) {
document.getElementById("hdnEvent").value = selva;
}
</script>
</telerik:RadCodeBlock>
<style type="text/css">
.ui-dialog-titlebar-close
{
visibility: hidden;
}
div.dataTables_wrapper
{
width: 1000px;
}
th
{
cursor: pointer;
background-color: #dadada;
color: Black;
font-weight: bold;
text-align: left;
width: auto;
}
th.headerSortUp
{
background-image: url(Scripts/asc.gif);
background-position: right center;
background-repeat: no-repeat;
}
th.headerSortDown
{
background-image: url(Scripts/desc.gif);
background-position: right center;
background-repeat: no-repeat;
}
.dataTables_wrapper .ui-toolbar
{
padding: 0px;
}
#ExportMasterDataButton
{
border: 0;
width: 129px;
height: 31px;
background: url('Images/Export-excel-1.png') no-repeat;
cursor: pointer;
}
</style>
</head>
<body>
<uc1:Top ID="Top1" runat="server" />
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<div class="navigation-main">
<div class="navigation">
<ul>
<li><a href="#" style="background: none repeat scroll 0 0 #1FBBA6; color: #FFFFFF;
cursor: default; text-shadow: 1px 1px 1px #474A4D; border-radius: 5px 5px 0 0;
display: block; margin-right: 5px; padding: 10px 20px 7px; text-decoration: none;
width: auto;">Extended Registration Data</a></li>
</ul>
</div>
</div>
<div class="choose-video-header">
<div class="choose-video-inner">
<div class="choose-text">
Extended Registration Data Report
</div>
<div class="choose-text-child">
</div>
</div>
</div>
<div class="main-body" style="width: 1000px">
<uc1:TimeFrame ID="TimeFrame1" runat="server" />
<%--<% if (parentcompany_id != 2840 && parentcompany_id == 2960)
{ %>
<div class="Drop-down-div" style="clear:both" >
<div style="margin-top: 5px; clear:both; width: 74px" class="Drop-down-child">Other Filter </div>
<div class="Drop-down-child">
<uc1:EventFilter ID="EventFilter1" runat="server" />
</div>
<div class="Drop-down-child">
<uc1:Status ID="Status1" runat="server" />
</div>
</div>
<%} %>--%>
<div class="Drop-down-div">
<span style=" padding-left:140px">
<uc1:ShowAll ID="ShowAll1" runat="server" />
</span>
</div>
<div class="message"><asp:Literal ID="ltMessage" Visible="false" runat="server" Text="No viewings are available"></asp:Literal></div>
<div style=" width:1000px; overflow-x:auto; margin:auto">
<telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" AutoGenerateColumns="false" PageSize="100"
AllowPaging="true" OnDataBound="RadGrid1_OnDataBound" OnSortCommand="RadGrid1_OnSortCommand"
AllowSorting="true" AllowCustomPaging="true" OnItemCommand="RadGrid1_OnItemCommand"
CellSpacing="1" Style="padding: 1px;" Skin="Default" OnNeedDataSource="RadGrid1_OnNeedDataSource"
OnExportCellFormatting="RadGrid1_ExportCellFormatting" OnHTMLExporting="RadGrid1_OnHtmlExporting">
<ItemStyle Wrap="false"></ItemStyle>
<ClientSettings>
<Selecting AllowRowSelect="False" />
<Scrolling AllowScroll="true" ScrollHeight="500px" />
</ClientSettings>
<ExportSettings Excel-Format="Html" ExportOnlyData="true" IgnorePaging="true" UseItemStyles="true"
OpenInNewWindow="true">
</ExportSettings>
<MasterTableView Name="ViewingDataForUsers" CommandItemDisplay="Top" TableLayout="Fixed">
<HeaderStyle Font-Size="14px" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True" />
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" />
<CommandItemTemplate>
<asp:Button ID="ExportMasterDataButton" runat="server" CommandName="ExportMasterData"
ClientIDMode="Static"></asp:Button>
</CommandItemTemplate>
</MasterTableView>
<FilterMenu EnableImageSprites="False" />
<PagerStyle PageSizeControlType="RadDropDownList" />
</telerik:RadGrid>
</div>
<div class="clear">
</div>
</div>
<div id="overlay" class="web_dialog_overlay"></div>
<uc1:Datefilter ID="DFilter" runat="server" />
<input type="hidden" id="hdnStartDate" runat="server" />
<input type="hidden" id="hdnEndDate" runat="server" />
<input type="hidden" id="hdnEvent" runat="server" value="-1" />
<input type="hidden" id="hdnStatus" runat="server" value="-1" />
</form>
</body>
</html>
and code in aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IntegratedSystem.VendorUserReport.Objects;
using Telerik.Web.UI;
namespace IntegratedSystem.VendorUserReport
{
public partial class ViewingExtendedRegistration : System.Web.UI.Page
{
public string Message = string.Empty;
public int parentcompany_id = 0;
protected int Userid = 0;
protected int UserLevel = 0;
private int event_Id = 0;
private int regStatus_Id = 0;
protected string NameSpace = string.Empty;
public string DateStart = DateTime.Now.Date.AddDays(-Int32.Parse("30")).ToShortDateString();
protected string EndDate = "01/01/2040";
protected int virtualItemCount = 0;
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.TimeFrame1.ddlCount_Change_Event += new Control.TimeFrame.FiltereByddlCount(this.ddlCount_Change_Event);
this.DFilter.DateFilter_Search_Click += new Control.DateFilter.FilterByDateRange(this.DateFilter_Search_Click);
this.TimeFrame1.ddlWeek_Change_Event += new Control.TimeFrame.FiltereByIndex(this.ddlWeeks_Change_Event);
this.ShowAll1.ShowAll_Click += new Control.ShowAll.ShowAllList(this.ShowAll1_ShowAll_Click);
}
protected void Page_Load(object sender, EventArgs e)
{
HttpCookieCollection MyCookieCollection = new HttpCookieCollection();
MyCookieCollection = Request.Cookies;
HttpCookie myCookie = MyCookieCollection.Get("ClientUser");
if (!string.IsNullOrEmpty(myCookie["UID"]) && !string.IsNullOrEmpty(myCookie["PC"]))
{
if (myCookie["PC"] != "")
{
parentcompany_id = Int32.Parse(myCookie["PC"]);
Userid = Int32.Parse(myCookie["UID"]);
UserLevel = Int32.Parse(myCookie["UL"]);
NameSpace = myCookie["PCNS"].ToString();
}
if (myCookie["RUID"] != "")
{
Userid = Int32.Parse(myCookie["RUID"]);
parentcompany_id = 5250;
NameSpace = "DODS_Main";
}
AddColumnsInRadGrid();
}
else
{
Server.Transfer("../SSBT/error.aspx");
}
}
protected DataTable GetData(string startDate, string endDate, string sortBy, string sortDirection, int pageNum, int pageSize)
{
return ViewingHelper.ViewingByExtendedRegistrationList(this.parentcompany_id, this.Userid, this.UserLevel, startDate ?? DateStart, endDate ?? EndDate,
sortBy, sortDirection, pageNum, pageSize,Convert.ToInt32( hdnEvent.Value), Convert.ToInt32(hdnStatus.Value), ref virtualItemCount, ref Message);
}
protected void DateFilter_Search_Click()
{
this.DateStart = this.DFilter.GetStartDate();
this.EndDate = this.DFilter.GetEndDate();
//BindGrid(parentcompany_id, Userid, UserLevel, DateStart, EndDate, event_Id, regStatus_Id, ref Message);
}
protected void ddlWeeks_Change_Event()
{
this.DateStart = this.TimeFrame1.SelectedDateRange;
//BindGrid(parentcompany_id, Userid, UserLevel, DateStart, EndDate, event_Id, regStatus_Id, ref Message);
}
protected void ddlCount_Change_Event()
{
this.DateStart = this.TimeFrame1.SelectedDateRange;
//BindGrid(parentcompany_id, Userid, UserLevel, DateStart, EndDate, event_Id, regStatus_Id, ref Message);
}
protected void ShowAll1_ShowAll_Click()
{
ViewState["DateStart"] = hdnStartDate.Value;
ViewState["EndDate"] = hdnEndDate.Value;
RadGrid1.Rebind();
}
private void AddColumnsInRadGrid()
{
RadGrid1.Columns.Clear();
if (parentcompany_id == 2840)
{
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "Registration Date";
col1.DataField = "Registration_Date";
col1.SortExpression = "";
col1.DataFormatString = "{0:d}";
col1.ItemStyle.Width = 100;
RadGrid1.Columns.Add(col1);
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "Traffic Source";
col2.DataField = "Promo_Code";
col2.SortExpression = "Promo_Code";
RadGrid1.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
col3.HeaderText = "Last Name";
col3.DataField = "Last_Name";
col3.SortExpression = "Last_Name";
RadGrid1.Columns.Add(col3);
GridBoundColumn col4 = new GridBoundColumn();
col4.HeaderText = "First Name";
col4.DataField = "First_Name";
col4.SortExpression = "First_Name";
RadGrid1.Columns.Add(col4);
GridBoundColumn col5 = new GridBoundColumn();
col5.HeaderText = "Company Name";
col5.DataField = "Company_Name";
col5.ItemStyle.Width = 100;
col5.SortExpression = "Company_Name";
RadGrid1.Columns.Add(col5);
GridBoundColumn col6 = new GridBoundColumn();
col6.HeaderText = "Address Line 1";
col6.DataField = "Address_Line_1";
col6.SortExpression = "Address_Line_1";
RadGrid1.Columns.Add(col6);
GridBoundColumn col7 = new GridBoundColumn();
col7.HeaderText = "Address Line 2";
col7.DataField = "Address_Line_2";
col7.SortExpression = "Address_Line_2";
RadGrid1.Columns.Add(col7);
GridBoundColumn col8 = new GridBoundColumn();
col8.HeaderText = "City";
col8.DataField = "city";
col8.SortExpression = "city";
RadGrid1.Columns.Add(col8);
GridBoundColumn col9 = new GridBoundColumn();
col9.HeaderText = "State";
col9.DataField = "state";
col9.SortExpression = "state";
RadGrid1.Columns.Add(col9);
GridBoundColumn col10 = new GridBoundColumn();
col10.HeaderText = "Zip/Postal Code";
col10.DataField = "Postal_Code";
col10.SortExpression = "Postal_Code";
RadGrid1.Columns.Add(col10);
GridBoundColumn col11 = new GridBoundColumn();
col11.HeaderText = "Country";
col11.DataField = "CountryName";
col11.SortExpression = "CountryName";
RadGrid1.Columns.Add(col11);
GridBoundColumn col12 = new GridBoundColumn();
col12.HeaderText = "Phone";
col12.DataField = "Phone";
col12.SortExpression = "Phone";
RadGrid1.Columns.Add(col12);
GridBoundColumn col13 = new GridBoundColumn();
col13.HeaderText = "Email Address";
col13.DataField = "Email_Address";
col13.SortExpression = "Email_Address";
RadGrid1.Columns.Add(col13);
GridBoundColumn col14 = new GridBoundColumn();
col14.HeaderText = "Title";
col14.DataField = "Title";
col14.SortExpression = "Title";
RadGrid1.Columns.Add(col14);
}
else
{
if (parentcompany_id == 2960)
{
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "Registration Date";
col1.DataField = "Registration_Date";
col1.DataFormatString = "{0:d}";
col1.SortExpression = "Registration_Date";
RadGrid1.Columns.Add(col1);
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "Traffic Source";
col2.DataField = "Promo_Code";
col2.SortExpression = "Promo_Code";
RadGrid1.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
col3.HeaderText = "Last Name";
col3.DataField = "Last_Name";
col3.SortExpression = "Last_Name";
RadGrid1.Columns.Add(col3);
GridBoundColumn col4 = new GridBoundColumn();
col4.HeaderText = "First Name";
col4.DataField = "First_Name";
col4.SortExpression = "First_Name";
RadGrid1.Columns.Add(col4);
GridBoundColumn col5 = new GridBoundColumn();
col5.HeaderText = "Email Address";
col5.DataField = "Email_Address";
col5.SortExpression = "Email_Address";
RadGrid1.Columns.Add(col5);
GridBoundColumn col6 = new GridBoundColumn();
col6.HeaderText = "Company Name";
col6.DataField = "Company_Name";
col6.ItemStyle.Width = 100;
col6.SortExpression = "Company_Name";
RadGrid1.Columns.Add(col6);
GridBoundColumn col8 = new GridBoundColumn();
col8.HeaderText = "City";
col8.DataField = "city";
col8.SortExpression = "city";
RadGrid1.Columns.Add(col8);
GridBoundColumn col9 = new GridBoundColumn();
col9.HeaderText = "State";
col9.DataField = "state";
col9.SortExpression = "state";
RadGrid1.Columns.Add(col9);
GridBoundColumn col10 = new GridBoundColumn();
col10.HeaderText = "Zip/Postal Code";
col10.DataField = "Postal_Code";
col10.SortExpression = "Postal_Code";
RadGrid1.Columns.Add(col10);
GridBoundColumn col11 = new GridBoundColumn();
col11.HeaderText = "Country";
col11.DataField = "CountryCode";
col11.SortExpression = "CountryCode";
RadGrid1.Columns.Add(col11);
GridBoundColumn col12 = new GridBoundColumn();
col12.HeaderText = "Phone";
col12.DataField = "Phone";
col12.SortExpression = "Phone";
RadGrid1.Columns.Add(col12);
}
else
{
GridBoundColumn col1 = new GridBoundColumn();
col1.HeaderText = "Registration Date";
col1.DataField = "Registration_Date";
col1.DataFormatString = "{0:d}";
col1.ItemStyle.Width = 100;
col1.SortExpression = "Registration_Date";
RadGrid1.Columns.Add(col1);
GridBoundColumn col2 = new GridBoundColumn();
col2.HeaderText = "Event Name";
col2.DataField = "Event_Name";
col2.SortExpression = "Event_Name";
RadGrid1.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
col3.HeaderText = "Registration Status";
col3.DataField = "Registration_Status";
col3.SortExpression = "Registration_Status";
RadGrid1.Columns.Add(col3);
GridBoundColumn col4 = new GridBoundColumn();
col4.HeaderText = "First Name";
col4.DataField = "First_Name";
col4.SortExpression = "First_Name";
RadGrid1.Columns.Add(col4);
GridBoundColumn col41 = new GridBoundColumn();
col41.HeaderText = "Last Name";
col41.DataField = "Last_Name";
col41.SortExpression = "Last_Name";
RadGrid1.Columns.Add(col41);
GridBoundColumn col5 = new GridBoundColumn();
col5.HeaderText = "Email Address";
col5.DataField = "Email_Address";
col5.SortExpression = "Email_Address";
RadGrid1.Columns.Add(col5);
GridBoundColumn col6 = new GridBoundColumn();
col6.HeaderText = "Phone";
col6.DataField = "Phone";
col6.SortExpression = "Phone";
RadGrid1.Columns.Add(col6);
GridBoundColumn col7 = new GridBoundColumn();
col7.HeaderText = "Address Line 1";
col7.DataField = "Address_Line_1";
col7.SortExpression = "Address_Line_1";
RadGrid1.Columns.Add(col7);
GridBoundColumn col8 = new GridBoundColumn();
col8.HeaderText = "City";
col8.DataField = "city";
col8.SortExpression = "city";
RadGrid1.Columns.Add(col8);
GridBoundColumn col9 = new GridBoundColumn();
col9.HeaderText = "State";
col9.DataField = "state";
col9.SortExpression = "state";
RadGrid1.Columns.Add(col9);
GridBoundColumn col10 = new GridBoundColumn();
col10.HeaderText = "Zip/Postal Code";
col10.DataField = "Postal_Code";
col10.SortExpression = "Postal_Code";
RadGrid1.Columns.Add(col10);
GridBoundColumn col11 = new GridBoundColumn();
col11.HeaderText = "Country";
col11.DataField = "CountryName";
col11.SortExpression = "CountryName";
RadGrid1.Columns.Add(col11);
GridBoundColumn col12 = new GridBoundColumn();
col12.HeaderText = "Title";
col12.DataField = "Title";
col12.SortExpression = "Title";
RadGrid1.Columns.Add(col12);
GridBoundColumn col13 = new GridBoundColumn();
col13.HeaderText = "Company Name";
col13.DataField = "Company_Name";
col13.ItemStyle.Width = 100;
col13.SortExpression = "Company_Name";
RadGrid1.Columns.Add(col13);
}
}
}
protected void RadGrid1_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
int startRowIndex = HasRecords() ? RadGrid1.CurrentPageIndex + 1 : 1;
string startDate = !IsPostBack ? DateStart : (string)ViewState["DateStart"];
string endDate = !IsPostBack ? EndDate : (string)ViewState["EndDate"];
string sortBy = (string)ViewState["SortBy"];
string sortDirection = (string)ViewState["SortDirection"];
RadGrid1.DataSource = GetData(startDate, endDate, sortBy, sortDirection, startRowIndex, RadGrid1.PageSize);
RadGrid1.VirtualItemCount = virtualItemCount;
}
protected void RadGrid1_OnSortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)
{
//e.Canceled = true;
if ((string)ViewState["SortBy"] != e.SortExpression)
{
ViewState["SortDirection"] = "desc";
}
ViewState["SortBy"] = e.SortExpression;
string startDate = !IsPostBack ? DateStart : (string)ViewState["DateStart"];
string endDate = !IsPostBack ? EndDate : (string)ViewState["EndDate"];
ViewState["SortExpression"] = e.SortExpression;
RadGrid1.DataSource = GetData(startDate, endDate, (string)ViewState["SortExpression"], (string)ViewState["SortDirection"],
this.RadGrid1.CurrentPageIndex + 1, this.RadGrid1.PageSize);
RadGrid1.VirtualItemCount = virtualItemCount;
RadGrid1.DataBind();
if ((string)ViewState["SortDirection"] == "desc")
{
ViewState["SortDirection"] = "asc";
}
else
{
ViewState["SortDirection"] = "desc";
}
}
private bool HasRecords()
{
return RadGrid1.MasterTableView.Items.Count > 0;
}
protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "ExportMasterData")
{
RadGrid1.ExportSettings.FileName = "ExtendedRegistrationViewingReport";
RadGrid1.PageSize = RadGrid1.MasterTableView.PageSize;
RadGrid1.MasterTableView.ExportToExcel();
}
}
protected void RadGrid1_OnHtmlExporting(object sender, GridHTMLExportingEventArgs e)
{
e.Styles.Append("body { border:solid 0.1pt #CCCCCC; }");
e.Styles.Append("br { mso-data-placement: same-cell; }");
}
protected void RadGrid1_OnDataBound(object sender, EventArgs e)
{
if (RadGrid1.Items.Count == 0)
{
RadGrid1.Visible = false;
ltMessage.Visible = true;
ClientScript.RegisterStartupScript(this.GetType(), "IsNotAvailable", "IsNotAvailable();", true);
}
else
{
RadGrid1.Visible = true;
ltMessage.Visible = true;
ltMessage.Text = Message;
}
}
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
GridDataItem item = e.Cell.Parent as GridDataItem;
if (item == null)
{
return;
}
item.Style["text-align"] = "left";
}
}
}
Please let me know what i am doing wrong or missing something
Any help will be great
Thanks & Regards
Bharat