Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
186 views
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

Bharat
Top achievements
Rank 1
 answered on 10 Feb 2014
2 answers
146 views
Hello, I experience incorrect window resize when window placed on top of OpenLayers map. The issue appears with OpenLayers 2.13, in 2.12 it works as expected.

Here's sample code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
  CodeBehind="WebForm2.aspx.cs" Inherits="WebGisGeo.WebForm2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
  <script type="text/javascript" src="http://www.openlayers.org/dev/OpenLayers.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div id="map" style="width: 800px; height: 800px">
  </div>
  <telerik:RadWindow ID="_wndAttributeEditor" runat="Server" Title="Attribute Editor"
    Width="400" Height="550" VisibleOnPageLoad="false" Behaviors="Move, Resize, Maximize"
    Left="20" Top="170" EnableShadow="true">
    <ContentTemplate>
      <div id="_dvEditorWindowContent">
      </div>
    </ContentTemplate>
  </telerik:RadWindow>
  <input type="button" value="show" onclick="showwnd(); return false;" />
  <script type="text/javascript">
    function showwnd() {
      var editorWindow = $find("<%=_wndAttributeEditor.ClientID%>");
      editorWindow.show();
    }
    function init() {
      map = new OpenLayers.Map({
        div: "map",
        allOverlays: true,
        maxExtent: new OpenLayers.Bounds(1549471.9221, 6403610.94, 1550001.32545, 6404015.8)
      });
    }
  </script>
</asp:Content>

Any help appreciated, thanks in advance!
Andreas
Top achievements
Rank 1
 answered on 10 Feb 2014
0 answers
87 views
Dears,
I have PDF Stream returned from a service, i need to view it on the browser without having adobe Photoshop installed
Wael
Top achievements
Rank 1
 asked on 10 Feb 2014
1 answer
83 views
Hi,
Inside my grid I have a NestedViewTemplate with Listbox and grid.

<telerik:RadGrid ID="TaskRadGrid" runat="server" OnNeedDataSource="RadGrid_NeedDataSource"
 AllowPaging="True" OnItemCommand="RadGrid_ItemCommand"
                AllowSorting="True" OnItemInserted="RadGrid_ItemInserted" OnPreRender="RadGrid_PreRender"
                OnItemDataBound="RadGrid_ItemDataBound">
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id, Ambiente, Asset.Id"
                    HierarchyLoadMode="Client" Name="Task" CommandItemDisplay="Top">
                    <NestedViewTemplate>
                        <div style="width: 100%">
<telerik:RadSplitter ID="RadSplitter1" runat="server" Height="250" Width="100%">
    <telerik:RadPane ID="MiddlePane" runat="server">
                                    <telerik:RadSplitter ID="RadSplitter2" runat="server" Height="400" Width="100%">
                                        <telerik:RadPane ID="RadPane1" runat="server" Width="24" Scrolling="None" Height="100px">
                                            <telerik:RadSlidingZone ID="RadSlidingZone1" runat="server" Width="24" ClickToOpen="true"
                                                Height="100px">
                                                <telerik:RadSlidingPane ID="CatalogOperationsRadSlidingPane" Title="Catalog operations (Drag&Drop record into the grid)" runat="server" Height="100px" DockOnOpen="true"
                                                    IconUrl="img/gears.png" Width="150px">
                                                    <asp:ListBox runat="server" ID="CatalogOperationListBox" DataTextField="CodeAndDescription" DataValueField="Id"
                                                    EnableDragAndDrop="True"                                                  
                                                    Width="100%" Height="100%"></asp:ListBox>
                                                </telerik:RadSlidingPane>
                                            </telerik:RadSlidingZone>
                                        </telerik:RadPane>
                                        <telerik:RadSplitBar ID="RadSplitBar2" runat="server">
                                        </telerik:RadSplitBar>
                                        <telerik:RadPane ID="RadPane2" runat="server" Width="100%">
                                            <telerik:RadGrid ID="TaskOperationsRadGrid" runat="server" OnNeedDataSource="TaskOperationsRadGrid_NeedDataSource"
                                           OnItemCommand="TaskOperationsRadGrid_ItemCommand"
                                            OnItemDataBound="TaskOperationsRadGrid_ItemDataBound" >
                                                <MasterTableView AutoGenerateColumns="False" EditMode="InPlace" DataKeyNames="Id, Ambiente"
                                                    Name="TaskOperations" CommandItemDisplay="Top">
                                                    <CommandItemSettings AddNewRecordText="" RefreshText="" />                                       
                                                    <Columns>
                                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"
                                                            HeaderStyle-Width="70px" UpdateImageUrl="App_Themes/Default/Grid/Update.gif"
                                                            EditImageUrl="App_Themes/Default/Grid/Edit.gif" CancelImageUrl="App_Themes/Default/Grid/Cancel.gif"
                                                            InsertImageUrl="App_Themes/Default/Grid/Update.gif">
                                                            <HeaderStyle Width="70px"></HeaderStyle>
                                                        </telerik:GridEditCommandColumn>
                                                        <telerik:GridBoundColumn DataField="CodeAndDescription" HeaderText="Operation" SortExpression="CodeAndDescription"
                                                            HeaderStyle-Width="120px" MaxLength="45" UniqueName="Operation">
                                                            <HeaderStyle Width="120px"></HeaderStyle>
                                                        </telerik:GridBoundColumn>
                                                      
                                                        <telerik:GridBoundColumn DataField="Remarks" HeaderText="Remarks" SortExpression="Remarks"
                                                            HeaderStyle-Width="120px" MaxLength="45" UniqueName="Remarks">
                                                            <HeaderStyle Width="120px"></HeaderStyle>
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridButtonColumn Text="Delete" CommandName="Delete" UniqueName="DeleteColumn"
                                                            ButtonType="ImageButton" ConfirmText="Are you sure?" HeaderStyle-Width="35px"
                                                            ImageUrl="App_Themes/Default/Grid/Delete.gif">
                                                            <HeaderStyle Width="35px"></HeaderStyle>
                                                        </telerik:GridButtonColumn>
                                                    </Columns>
                                                    <EditFormSettings>
                                                        <EditColumn ButtonType="ImageButton" />
                                                    </EditFormSettings>
                                                </MasterTableView>
                                                <ClientSettings>
                                                    <ClientEvents OnRowDblClick="RowDblClick" OnHierarchyExpanding="CollapseOtherRows">
                                                    </ClientEvents>
                                                </ClientSettings>
                                            </telerik:RadGrid>
                                        </telerik:RadPane>
                                    </telerik:RadSplitter>
                                </telerik:RadPane>
                            </telerik:RadSplitter>
  </div>
                    </NestedViewTemplate>
                    <Columns>
.....
</Column>
</MasterTableView>
  </telerik:RadGrid>

I want to drag item from listbox to radgrid. Is it possible?
Do you have some example?

Thanks
Shinu
Top achievements
Rank 2
 answered on 10 Feb 2014
1 answer
114 views
Hi,

In your webclient demo, when I select a new folder, the grid is updating
During this updating, you display an image for wating in the center in the datagrid
I don't find how to do that

Can you help me

I need to reproduce the same when I have a call to server

Thanks
Sylo
Princy
Top achievements
Rank 2
 answered on 10 Feb 2014
4 answers
94 views

The datasource for my RadGrid is a simple datatable. The grid has a GridClientDeleteColumn object. When I click delete, I want to remove the row from the grid and delete the row from the datatable the grid is bound to via NeedDataSource. I'm using RadAjaxManager.

To do all this, I call a javascript function via OnRowDeleting. From there I get the row's unique key via eventArgs.getDataKeyValue and pass it to a server-side function that has a WebMethod attribute. It deletes the row from the datatable. (If this is not the simplest/best way, then please advise.)

Anyway, it works great!... unless I delete the bottom row in the grid. Then when the grid refreshes, I get this error...

JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Specified argument was out of the range of valid values.
Parameter name: ItemHierarchicalIndex

It's not a particular row, but always the bottom row. I know this because I can sort the row by various columns, but only when I delete the bottom row and it refreshes do I get the error.

While trying to debug, on a whim, I put this line first in my javascript function that OnRowDeleting calls...

eventArgs.set_cancel(true);

Now when I delete the bottom row, as expected, it does not remove the row from the grid. However, when the grid is refreshed, I don't get the error and the row is gone because it was indeed deleted from the table on server-side.

What's the problem? Why does everything work unless it's the bottom row? And again, if there's a simpler/better way in general to remove the grid row and delete it from the datatable, then please advise.

Shinu
Top achievements
Rank 2
 answered on 10 Feb 2014
1 answer
20 views
In thi scode Cc is server side varibale . but it throw an error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

<body class="demoMail">
    <form id="form" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" EnableRoundedCorners="False"
        DecoratedControls="All" />
    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">DemoMail</a></li>
            <li><a href="#tabs-3">DemoMail Sentbox</a></li>
            <% if (Cc==2)
             {%>
            <li><a href="#tabs-2">Constant Contact Report</a></li>
            <%}%>
              <% if (mm==3)
             {%>
            <li><a href="#tabs-4">Marketo Report</a></li>
              <%}%>
        </ul>
plz post me a solution asap
thanks
Shinu
Top achievements
Rank 2
 answered on 10 Feb 2014
6 answers
84 views
Hi, 

I am not sure if this is the correct place to post this question but I hope so....

I am maintaining an existing app hat I have just been given and have 3 RADGRIDs which are identical and used for 3 types of transactions. I have several columns with a button at the end, with a row added to the bottom to have comments on the 2nd line of each transaction.

The button is to add comments and I want to get the current comments and put this into the dialog box when the add btn is clicked.

The problem I am having is that I dont know how to access the correct Row (the following example just gives me the 1st row and not the ROW whos add button was clicked and from which RADGRID.

Here is the code I found on you site which gives me the comments for the first transaction only and the radgrids after thet.

Thanks, George.

var grid = $find("RadGrid1").get_element();
var CommentsElement = $telerik.findElement(grid, "CommentsField");
if (CommentsElement)
$("#txtAddComment").val(CommentsElement.outerText); 



<telerik:RadGrid runat="server" ID="RadGrid1" HeaderStyle-HorizontalAlign="Left" 
<MasterTableView>
    <Columns>
        <telerik:GridTemplateColumn HeaderText="ID" ItemStyle-Width="200px" Display="false">
            <ItemTemplate>
                <asp:Label runat="server" ID="ID" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>' />
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Name" ItemStyle-Width="150px">
             <ItemTemplate>
                  <asp:Label runat="server" ID="NAME" Text='<%# DataBinder.Eval(Container.DataItem, "NAME")%>' />
             </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Add Comments">
             <ItemTemplate>
                <telerik:RadButton runat="server" Text="Add" ID="AddCommentBtn" OnClientClicked="AddCommentBtn_Clicked" AutoPostBack="false"  />
           </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
    <DetailItemTemplate>
        <asp:Table ID="ColumnRow" runat="server">
            <asp:TableRow>
                <asp:TableCell>
                      <asp:Label runat="server" ID="CommentsField" Text='<%# DataBinder.Eval(Container.DataItem, "COMMENTS")%>' 
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </DetailItemTemplate>
</MasterTableView>
</telerik:RadGrid>


<telerik:RadGrid runat="server" ID="RadGrid2" HeaderStyle-HorizontalAlign="Left" 
<MasterTableView>
    <Columns>
        <telerik:GridTemplateColumn HeaderText="ID" ItemStyle-Width="200px" Display="false">
            <ItemTemplate>
                <asp:Label runat="server" ID="ID" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>' />
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Name" ItemStyle-Width="150px">
             <ItemTemplate>
                  <asp:Label runat="server" ID="NAME" Text='<%# DataBinder.Eval(Container.DataItem, "NAME")%>' />
             </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Add Comments">
             <ItemTemplate>
                <telerik:RadButton runat="server" Text="Add" ID="AddCommentBtn2" OnClientClicked="AddCommentBtn_Clicked" AutoPostBack="false"  />
           </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
    <DetailItemTemplate>
        <asp:Table ID="ColumnRow" runat="server">
            <asp:TableRow>
                <asp:TableCell>
                      <asp:Label runat="server" ID="CommentsField" Text='<%# DataBinder.Eval(Container.DataItem, "COMMENTS")%>' 
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </DetailItemTemplate>
</MasterTableView>
</telerik:RadGrid>
Princy
Top achievements
Rank 2
 answered on 10 Feb 2014
1 answer
73 views
I need to do error checking on a page and it happens on the selectedtabevent.  If the page errors out I need them to stay on teh current tab and not go forward until they have picked what they need to do.  So I thought i could se tthe selected index but it seems not to work.  Is there another way to do this?

function CheckValidation(sender, args) {
           var tab1 = sender.get_selectedIndex();
           if (tab1 == 1) {
               var combo = $find('<%= ddlSoldCounty.ClientID %>');
               var item = combo.get_value();
               if (item = 0)  {
                   if (tab1 == 1) {
                       //Set the selected tab back to 0
                       tab1.sender.set_selectedIndex == 0;
                   }
                   alert('You must pick a county from Drop Down List');
               }
           }
       }
Shinu
Top achievements
Rank 2
 answered on 10 Feb 2014
0 answers
121 views
Hi Everyone

i am making Webmail like this http://demos.telerik.com/aspnet-ajax/webmail/ 
but problem is that.. How to show Total UnRead Email in inbox..
Example: Yahoo or other email sites inbox show Total Unread email
how to do this..?

Thanks
In Advance
Arsalan
Top achievements
Rank 1
 asked on 09 Feb 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?