Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
33 views
Hi,

I'd like to use the Grid control to allow for inserting, updating and deleting items. The tricky part is the support of lookup to already existing records on insert/update.

In insert/edit mode, the first textbox will be a lookup, in which the other fields in the row will be filled in if found in DB. If not found, it will be inserted to DB as a new record.

Example:
I enter the ISBN number of a book and make a lookup in the DB to see if it's found, populate the other fields and save it as a row. If ISBN number is not found, then fill out all fields and save it as a new record to the DB.

Any tips about useful articles or code examples are appreciated.
Shinu
Top achievements
Rank 2
 answered on 13 May 2011
5 answers
261 views
Is it possible to put controls (ie. buttons) next to the caption of a radPanelBarItem?

Thanks.
Helen
Telerik team
 answered on 13 May 2011
1 answer
81 views
Hello,

I have a raddock with custom commands. I wish to replace custom command icon with a loading gif image when that icon is clicked till the time dock get refreshed completely. Then get back to original icon.

Can you please suggest how to do that ?
Pero
Telerik team
 answered on 13 May 2011
1 answer
91 views
Hi ,

    I have used rad window in my pjt.  it was working. when i move the rad window manager inside rad ajax panel it stopped working and throwing error like,"Cannot called after dispose"..

Here is the code

       function OpenRadWindowAddRecurrencePopup(isConflict, startDate, endDate, startTime, EndTime, SessionID, recordid, LOCATIONname, roomNo) {
                var Url = "./AddRecurrence.aspx?ISCONFLICT=" + isConflict + "&STARTDATE=" + startDate + "&ENDDATE=" + endDate + "&STARTTIME=" + startTime + "&ENDTIME=" + EndTime + "&SESSIONID=" + SessionID + "&CODE=" + recordid + "&LOCATIONID=" + LOCATIONname + "&roomNo=" + roomNo;
                var oWnd = radopen(Url, "radWindowAddRecurrencePopup");
                //oWnd.SetUrl(oWnd.GetUrl());
                return false;
            }
  
    <telerik:RadAjaxPanel>
// some controls here
 <telerik:RadWindowManager ID="RadWindowManager2" runat="server" MinWidth="500" ReloadOnShow="false">
            <Windows>
                <telerik:RadWindow ID="radWindowAccountCodePopup" OnClientClose="CallBackFunctionAccountCode"
                    Behavior="Close" VisibleTitlebar="false" Modal="true" Width="650px" runat="server"
                    Height="530px" NavigateUrl="~\Admin\AccountCodePopup.aspx" VisibleStatusbar="false">
                </telerik:RadWindow>
                <telerik:RadWindow ID="radWindowAddRecurrencePopup" Modal="true" Width="750px" runat="server"
                    Height="650px" OnClientClose="CallBackFunctionRecurrence" InitialBehaviors="None">
                    <%--OnClientClose="CallBackFunctionRecurrence"--%>
                </telerik:RadWindow>
                <telerik:RadWindow ID="radWindowViewEditRecurremcePopup" OnClientClose="CallBackFunctionRecurrence"
                    Behaviors="None" VisibleTitlebar="false" Modal="true" Width="700px" runat="server"
                    Height="450px" VisibleStatusbar="false">
                </telerik:RadWindow>
                <telerik:RadWindow ID="radWindowLocationPopup" OnClientClose="CallBackFunctionService"
                    OpenerElementID="" OffsetElementID="" Behavior="Close" VisibleTitlebar="false"
                    Modal="true" Width="578px" runat="server" Height="450px" NavigateUrl="~\Admin\LocationPopup.aspx"
                    VisibleStatusbar="false">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
    </telerik:RadAjaxPanel>


thx
esther
Georgi Tunev
Telerik team
 answered on 13 May 2011
3 answers
175 views
Hi,

Im using Radgrid with AutoGenerateColumns="True" and the column header will be like "Firstname, Lastname" (with Comma). While sorting the grid on column (Firstname, Lastname) with sort expression field name it throws error like "Cannot find column Firstname". Im using the following code in RadGrid1_SortCommand.

GridSortExpression sortExpr = new GridSortExpression();
switch (e.OldSortOrder)
        {
            case GridSortOrder.None:
                sortExpr.FieldName = e.SortExpression;
                sortExpr.SortOrder = GridSortOrder.Descending;
                e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr);
                Session["GridSort"] = GridSortOrder.Descending;
                break;
            case GridSortOrder.Descending:
                sortExpr.FieldName = e.SortExpression;
                sortExpr.SortOrder = GridSortOrder.Ascending;
                e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr);
                Session["GridSort"] = GridSortOrder.Ascending;
                break;
            case GridSortOrder.Ascending:
                sortExpr.FieldName = e.SortExpression;
                sortExpr.SortOrder = GridSortOrder.Descending;
                e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr);
                Session["GridSort"] = GridSortOrder.Descending;
                break;
        }
e.Canceled = true;
RadGrid1.Rebind();

Sample Grid: (2nd Column Header contains Comma)

S.No FirstName, LastName DOB City
1 XXX, X 11/11/1111 NJ
2 YYY, Y 11/11/1111 NJ
3 ZZZ, Z 11/11/1111 NJ

Please Reply ASAP.
Thanks in Advance.

Thanks,
Ranjith J
Tsvetoslav
Telerik team
 answered on 13 May 2011
5 answers
146 views
I have the next code, that it's executed after a postback inside a grid(www.tedit.net)

            ExcelFile efE = new ExcelFile(); 
            ExcelWorksheet wsE = efE.Worksheets.Add("email"); 
            Response.Clear(); 
            Response.ContentType = "application/vnd.ms-excel"
            Response.AddHeader("Content-Disposition""attachment; filename=" + e.Row["rowno"] + "_Email.xls"); 
            efE.SaveXls(Response.OutputStream); 
            Response.End(); 
 

I already see this next:
not-on-top-of-call-stack

My problem is when the code reaches Response.End it throws an exception error. In the link I mention, it doesnt say how to resolve the issue.

This is the error message:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Can you help please?

Daniel
Telerik team
 answered on 13 May 2011
7 answers
119 views

Hi,
We
 must ask the user about an operation during the process of the main thread. We currently use msgbox, depending on user response to make a decision or another.
We have updated RadControl from a previous version to the brand new version of the Telerik suite (2011.1.315.35) and we have seen that there is a new control that can reproduce the same action.

We
 would like to use Radwindows, radalert, etc, so that we can give our own style, keeping a similar CSS style of the application. The problem facing us is that through vb code for this control we must wait an answer from the user (like modal behaviour in WinFomrs).
We have done several test to make this behaviour possible.
We´ve seen that the RadWindow control appears after the code of the function finish instead of showing at the momment is being calledt.

is this a normal behaviour?.
Are we doing a bad implementation of the control?.

Kind regards.


Marin Bratanov
Telerik team
 answered on 13 May 2011
1 answer
237 views
Hi,

    I have used rad window. It was working fine wih IE8 and firefox. Recently i upgraded with telerik latest version. since then, the pop up is not getting opened with the width and height which i set.
 I have given the code of radwindow and javascript f unction call to open rad window below

 

<telerik:RadWindowManager ID="RadWindowManager2" runat="server"
<Windows>
 <telerik:RadWindow ID="radWindowAddRecurrencePopup" OnClientClose="CallBackFunctionRecurrence"  Behavior="Close" VisibleTitlebar="false" Modal="true" Width="750px" runat ="server" Height="650px" VisibleStatusbar="false"
</telerik:RadWindow>
</Windows
</telerik:RadWindowManager>
  
   function OpenRadWindowViewEditRecurrencePopup(isConflict, startDate, endDate, startTime, EndTime, SessionID, recordid, LOCATIONname, roomNo) {
                var Url = "./ViewEditSchedulePopUp.aspx?ISCONFLICT=" + isConflict + "&STARTDATE=" + startDate + "&ENDDATE=" + endDate + "&STARTTIME=" + startTime + "&ENDTIME=" + EndTime + "&SESSIONID=" + SessionID + "&CODE=" + recordid + "&LOCATIONID=" + LOCATIONname + "&roomNo=" + roomNo;
                var oWnd = radopen(Url, "radWindowViewEditRecurremcePopup");
                //oWnd.SetUrl(oWnd.GetUrl());
                return false;
            }

this problem is only with IE. it works in other browsers..
Is their any fixes for this issue?

Thx
Esther

 

 

 

 

Georgi Tunev
Telerik team
 answered on 13 May 2011
1 answer
225 views
My user control is displayed in a radwindow declared in page1. The web user control contains an asp:panel with it's defaultbutton set to a button on the web user control. Page1 also has a submit button.

If the radwindow content is focused, and I press enter, the button in the web user control works as expected.

If i click the radwindow's title bar or icon, the button in page1 is invoked; this is not desired.

As long as the window is displayed, only the web user control button should work.

<telerik:RadWindow ID="radWinAccountSearch" runat="server" Title="Account Search" Behaviors="Move, Reload" VisibleStatusbar="false" >
    <ContentTemplate>
        <ucAccountSearch:AccountSearch ID="AccountSearchControl" runat="server" OnAccountsSelected="AccountSearchControl_AccountsSelected" />
   </ContentTemplate>
</telerik:RadWindow>
Marin Bratanov
Telerik team
 answered on 13 May 2011
5 answers
376 views
Sorry if this is a duplicate post. The other one did not show up in the list so I assume it got lost somehow.

telerik version: 2011.1.315.40
browser: FF
.net 4.0
VS 2010.

I have a radgrid with a nestedviewtemplate containing another radgrid. I am exporting to excel using a button in the radtoolbar control.
I am using advanced databinding for the master and child grids. The grids render the data with no errors. However, when exporting this error is raised: I have researched many posts on various binding techniques and am wondering if its related to that. I had the export working before when I used client side binding. Attached below are the aspx and .cs files. Please Help and Thanks in Advance.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 
[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.UI.GridTableView.PrepareExport() +17
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExportInternal(GridTableView tableView, Boolean ignorePaging, Boolean dataOnly) +321
   Telerik.Web.UI.GridTableView.ClearTableViewControls(Control control, TableViewExporter exporter, GridTableView ownerTable) +583
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.PreRenderRecursiveInternal() +112
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4184
ASPX:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    var currentLoadingPanel = null;
    var currentUpdatedControl = null;
    function OnDateSelected(sender, e) {
        var monthPicker = $find("<%= RadMonthYearPicker.ClientID %>");
        var startDatePicker = $find("<%= RadDatePickerStartDate.ClientID %>");
        var endDatePicker = $find("<%= RadDatePickerEndDate.ClientID %>");
        var selectedMonth = monthPicker.get_selectedDate();
 
        //set start date default, min and max
        var year = selectedMonth.getFullYear();
        var month = selectedMonth.getMonth();
        var minDate = new Date(year, month, 1);
        var maxDate = new Date(year, month + 1, 0);
        startDatePicker.set_minDate(minDate);
        startDatePicker.set_maxDate(maxDate);
        startDatePicker.set_selectedDate(minDate);
 
        //set end date default, min and max
        endDatePicker.set_minDate(minDate);
        //need to be sure we dont go into the future
        endDatePicker.set_maxDate(maxDate);
        endDatePicker.set_selectedDate(maxDate);
    }
</script>
</telerik:RadCodeBlock>
 
 
<div  class="filter2-single-column-layout">
    <div  class="section">
      <div  class="content">
          <table>
                <tr>
                   <td>
                       Custom Date Range:
                   </td>
                   <td>
                       <asp:CheckBox ID="CheckBoxCustomDateRange" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBoxCustomDateRange_CheckedChanged"></asp:CheckBox>
                   </td>
                <td>  Or Select Month:</td>
                <td><telerik:RadMonthYearPicker ID="RadMonthYearPicker" Width="125px" runat="server"  >
                       <ClientEvents OnDateSelected="OnDateSelected"></ClientEvents>
                    </telerik:RadMonthYearPicker></td>
                   <td >
                      Start:
                   </td>
                   <td>
                       <telerik:RadDateTimePicker ID="RadDatePickerStartDate" Width="155px" runat="server" ShowPopupOnFocus="False"></telerik:RadDateTimePicker>
                   </td>
                   <td >
                      <asp:RequiredFieldValidator ID="RequiredFieldValidatorStartDate" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="RadDatePickerStartDate"></asp:RequiredFieldValidator>
                   </td>
                   <td>
                       End:
                   </td>
                   <td>
                       <telerik:RadDateTimePicker ID="RadDatePickerEndDate" Width="155px" runat="server" ShowPopupOnFocus="False"></telerik:RadDateTimePicker>
                        
                   </td>
                   <td>
                   <asp:RequiredFieldValidator ID="RequiredFieldValidatorEndDate" runat="server" ErrorMessage="*"  ForeColor="Red" ControlToValidate="RadDatePickerEndDate"></asp:RequiredFieldValidator>
                       <asp:CompareValidator ID="CompareValidator1" ControlToValidate="RadDatePickerStartDate" Operator="LessThanEqual" ControlToCompare="RadDatePickerEndDate" runat="server" ForeColor="Red" ErrorMessage="*"></asp:CompareValidator>
                   </td>
 
                   <td>
                   <telerik:RadToolBar runat="server" ID="RadToolBar" EnableRoundedCorners="True" OnButtonClick="RadToolBar_ButtonClick" AutoPostBack="true">
                     <Items >
                       <telerik:RadToolBarButton Text="Search" ToolTip="Search (Alt+S)" CommandName="search" ></telerik:RadToolBarButton>
                     </Items>
                   </telerik:RadToolBar>
                   </td>
                   <td>
                        <telerik:RadComboBox runat="server" ID="CustomerSelector"  Width="100px">
                            <Items>
                                <telerik:RadComboBoxItem Text="1001005" Value="1001005" />
                            </Items>
                        </telerik:RadComboBox>
                   </td>
                </tr>
             </table>
           </div>
     </div>
</div>
 
<div class="column-full">
<telerik:RadToolBar ID="gridtemplateButtons" runat="server" EnableEmbeddedBaseStylesheet="false" EnableEmbeddedSkins="false" OnButtonClick="gridtemplateButtons_ButtonClick" AutoPostBack="true" Height="22px">
<Items>
    <telerik:RadToolBarButton Text="Manage Cards..." ToolTip="" CommandName="ManageCards"></telerik:RadToolBarButton>
    <telerik:RadToolBarButton IsSeparator="true" />
    <telerik:RadToolBarDropDown Text="Export" AccessKey="e" ToolTip="Export (Alt+E)">
        <Buttons>
            <telerik:RadToolBarButton IsSeparator="true">
            </telerik:RadToolBarButton>
            <telerik:RadToolBarButton ImageUrl="~/Images/stratos_icon_16x16_settings3.gif" ImagePosition="Left" Text="Export MS Excel"  CommandName="ExportToExcel">
            </telerik:RadToolBarButton>
        </Buttons>
    </telerik:RadToolBarDropDown>
</Items>
</telerik:RadToolBar>
 
<telerik:RadGrid ID="RadGridTrafficSummary" EnableViewState="true" runat="server"
Visible="true" GroupingEnabled="true" AllowSorting="True" AllowPaging="True"
AllowFilteringByColumn="true" AllowMultiRowSelection="False" ShowStatusBar="true" AutoGenerateColumns="False"
 OnNeedDataSource="RadGridTrafficSummary_NeedDataSource"
 OnPreRender="RadGridTrafficSummary_PreRender"
 ShowFooter="true">
 <MasterTableView AutoGenerateColumns="False" DataKeyNames="imsi" Width="100%">
<PagerStyle Mode="NextPrevNumericAndAdvanced" />
<Columns>
        <telerik:GridBoundColumn FilterControlWidth="45px" HeaderStyle-Width="40px" ItemStyle-Width="20px" AllowFiltering="true" AllowSorting="false" HeaderTooltip="" DataType="System.String" DataField="accountnr" HeaderText="Acct #"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn FilterControlWidth="45px" HeaderStyle-Width="50px" ItemStyle-Width="40px" HeaderTooltip=""  DataType="System.String" DataField="customerId" HeaderText="Customer #"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn HeaderStyle-Width="80px" ItemStyle-Width="80px" HeaderTooltip="" DataField="cname"  DataType="System.String" HeaderText="Name"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn FilterControlWidth="40px" HeaderStyle-Width="40px" ItemStyle-Width="40px" HeaderTooltip=""  DataType="System.String" DataField="product" HeaderText="Product"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn HeaderStyle-Width="80px" ItemStyle-Width="80px" HeaderTooltip="" DataField="imsi" DataType="System.String" HeaderText="IMSI"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn HeaderStyle-Width="100px" ItemStyle-Width="100px" HeaderTooltip="" DataField="ICCID" DataType="System.String" HeaderText="ICCID"></telerik:GridBoundColumn>
        <telerik:GridNumericColumn FilterControlWidth="60px" HeaderStyle-Width="50px" ItemStyle-Width="50px" AllowFiltering="true" FooterStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" DataType="System.Decimal" HeaderStyle-HorizontalAlign="Right" HeaderTooltip="" DataField="MBsIn" HeaderText="MBs In"></telerik:GridNumericColumn >
        <telerik:GridNumericColumn FilterControlWidth="60px" HeaderStyle-Width="50px" ItemStyle-Width="50px" AllowFiltering="true"  FooterStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" DataType="System.Decimal" HeaderStyle-HorizontalAlign="Right" HeaderTooltip="" DataField="MBsOut" HeaderText="MBs Out"></telerik:GridNumericColumn >
        <telerik:GridNumericColumn FilterControlWidth="60px" HeaderStyle-Width="50px"  ItemStyle-Width="50px" AllowFiltering="true"  FooterStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" DataType="System.Decimal" HeaderStyle-HorizontalAlign="Right" HeaderTooltip="" DataField="MBsTotal" HeaderText="MBs Total" ></telerik:GridNumericColumn >
        <telerik:GridBoundColumn FilterControlWidth="35px" HeaderStyle-Width="35px" ItemStyle-Width="35px"  DataType="System.String" HeaderTooltip="To Unsubscribe, use the Manage Cards button." DataField="subscription" HeaderText="Subscribed"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn visible="false" DataType="System.String" DataField="startdate"></telerik:GridBoundColumn>
        <telerik:GridBoundColumn visible="false" DataType="System.String" DataField="enddate"></telerik:GridBoundColumn>
</Columns>
<NestedViewTemplate>
        <telerik:RadGrid runat="server" ID="RadGridTrafficImsiDetails" EnableViewState="true" GroupingEnabled="true" ShowFooter="true"
                    AllowFilteringByColumn="true" AllowSorting="true" >
                    <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true" PageSize="7" >
                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                            <Columns>
                            <telerik:GridBoundColumn visible="false" HeaderTooltip="" DataField="imsi" HeaderText="IMSI"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn visible="false" HeaderTooltip="" DataField="iccid" HeaderText="ICCID"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn FilterControlWidth="30px"  HeaderStyle-Width="20px" ItemStyle-Width="20px"    DataField="service" HeaderText="Service"></telerik:GridBoundColumn>
                            <telerik:GridNumericColumn  FilterControlWidth="60px" HeaderStyle-Width="40px" ItemStyle-Width="40px"  AllowFiltering="true"  FooterStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" DataType="System.Decimal" HeaderStyle-HorizontalAlign="Right" HeaderTooltip="" DataField="MBsIn" HeaderText="MBs In" HeaderStyle-Wrap="false"></telerik:GridNumericColumn>
                            <telerik:GridNumericColumn  FilterControlWidth="60px" HeaderStyle-Width="40px" ItemStyle-Width="40px" AllowFiltering="true"  FooterStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" DataType="System.Decimal" HeaderStyle-HorizontalAlign="Right" HeaderTooltip="" DataField="MBsOut" HeaderText="MBs Out"  HeaderStyle-Wrap="false"></telerik:GridNumericColumn>
                            <telerik:GridBoundColumn HeaderStyle-Width="30px"  ItemStyle-Width="30px"  HeaderTooltip="" DataField="srcip" HeaderText="Source IP"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-Width="30px" ItemStyle-Width="30px"  HeaderTooltip="" DataField="dstip" HeaderText="Dest IP"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-Width="60px" ItemStyle-Width="60px"  HeaderTooltip="" DataField="domain" HeaderText="Domain"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn FilterControlWidth="30px" HeaderStyle-Width="20px" ItemStyle-Width="20px"  HeaderTooltip="" DataField="Port" HeaderText="Port"></telerik:GridBoundColumn>
                            <telerik:GridDateTimeColumn FilterControlWidth="130px" HeaderStyle-Width="120px"  ItemStyle-Width="120px"  HeaderTooltip="" DataField="dstamp" HeaderText="Date"></telerik:GridDateTimeColumn>
                            <telerik:GridBoundColumn FilterControlWidth="30px" HeaderStyle-Width="20px"  ItemStyle-Width="20px"  HeaderTooltip="" DataField="Denied" HeaderText="Denied"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-Width="30px" ItemStyle-Width="30px"  HeaderTooltip="" DataField="reason" HeaderText="Reason"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  Visible="false" DataType="System.String"  DataField="subscription"></telerik:GridBoundColumn>
                            </Columns>            
                    </MasterTableView>
        </telerik:RadGrid>
</NestedViewTemplate>
</MasterTableView>      
</telerik:RadGrid>
</div>
CS codebehind:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;
using Stratos.Libraries.Data;
using Telerik.Charting;
using Telerik.Web.UI;
using Telerik.Web.UI.Calendar;
 
namespace Stratos.Web.Portal.Reports
{
    public partial class TrafficDashboard_01_export : System.Web.UI.Page
    {
        TimeSpan allowableTimeSpan = new TimeSpan(365, 0, 0, 0); //1 full year
 
        private void SetStartEndDateRange()
        {
            this.RadMonthYearPicker.MinDate = DateTime.Now.Subtract(allowableTimeSpan);
            this.RadMonthYearPicker.MaxDate = DateTime.Now;
            this.RadMonthYearPicker.SelectedDate = DateTime.Now;
 
            //set start/end date min/max
            this.RadDatePickerStartDate.MinDate = DateTime.Now.Subtract(allowableTimeSpan);
            this.RadDatePickerStartDate.MaxDate = DateTime.Now;
            this.RadDatePickerEndDate.MinDate = DateTime.Now.Subtract(allowableTimeSpan);
            this.RadDatePickerEndDate.MaxDate = DateTime.Now;
 
            this.RadDatePickerStartDate.Clear();
            this.RadDatePickerEndDate.Clear();
            this.RadDatePickerStartDate.SelectedDate = new DateTime(RadMonthYearPicker.SelectedDate.Value.Year, RadMonthYearPicker.SelectedDate.Value.Month, 1);
            this.RadDatePickerEndDate.SelectedDate = DateTime.Now.Subtract(new TimeSpan(0, 0, 1));
 
 
 
        }
 
        protected void Page_Init(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                SetStartEndDateRange();
            }
        }
 
        public void Page_Load(object sender, System.EventArgs e)
        {
            //if sdate edate strings are null. Load page as if we came from menu
            if (String.IsNullOrEmpty(Request.QueryString["StartDate"]) || String.IsNullOrEmpty(Request.QueryString["EndDate"]))
            {
            }
            //if sdate edate strings are not null, we came from somewhere with dates, load data with them.
            else
            {
                this.RadDatePickerStartDate.SelectedDate = DateTime.Parse((Request.QueryString["StartDate"].ToString())); //ToString("dd-MMM-yyyy HH:mm:ss");
                this.RadDatePickerEndDate.SelectedDate = DateTime.Parse((Request.QueryString["EndDate"].ToString()));
            }
 
        }
 
 
        protected void CheckBoxCustomDateRange_CheckedChanged(object sender, System.EventArgs e)
        {
            SetStartEndDateRange();
            if (CheckBoxCustomDateRange.Checked)
            {
                this.RadMonthYearPicker.Enabled = false;
            }
            else
            {
                this.RadMonthYearPicker.Enabled = true;
            }
 
        }
 
 
        protected void RadToolBar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
        {
            RadToolBarButton buttons = e.Item as RadToolBarButton;
            if (buttons.CommandName.ToString().ToLower() == "search")
            {
                RadGridTrafficSummary.Rebind();
            }
        }
 
 
        protected void gridtemplateButtons_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            RadToolBarButton gridtemplateButtons = e.Item as RadToolBarButton;
            if (gridtemplateButtons.CommandName.ToString().ToLower() == "exporttoexcel")
            {
                ConfigureExport(RadGridTrafficSummary);
                RadGridTrafficSummary.MasterTableView.ExportToExcel();
            }
        }
 
        protected void RadGridTrafficSummary_PreRender(object sender, EventArgs e)
        {
            foreach (GridDataItem gridDataItem in (sender as RadGrid).MasterTableView.Items)
            {
                if (gridDataItem.Expanded)
                {
                    GridNestedViewItem gridNestedViewItem = gridDataItem.ChildItem;
                    if (gridNestedViewItem != null)
                    {
                        RadGrid RadGridTrafficImsiDetails = (RadGrid)gridNestedViewItem.FindControl("RadGridTrafficImsiDetails");
                        RadGridTrafficImsiDetails.DataSource = NetStats.GetImsiDetailTraffic(GetScopeLimitation(), (DateTime)RadDatePickerStartDate.SelectedDate, (DateTime)RadDatePickerEndDate.SelectedDate, gridDataItem["imsi"].Text);
                        RadGridTrafficImsiDetails.DataBind();
                    }
                }
            }
        }
 
 
        private void ConfigureExport(object sender)
        {
            (sender as RadGrid).ExportSettings.ExportOnlyData = true;
            (sender as RadGrid).ExportSettings.IgnorePaging = true;
            (sender as RadGrid).MasterTableView.HierarchyDefaultExpanded = true;
 
        }
 
        protected void RadGridTrafficSummary_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            RadGridTrafficSummary.DataSource = NetStats.GetCustomerTrafficSummary(GetScopeLimitation(), (DateTime)RadDatePickerStartDate.SelectedDate, (DateTime)RadDatePickerEndDate.SelectedDate);
        }
 
        private String GetScopeLimitation()
        {
            //TODO build the users scope limitation, a list of customer and sub customers that they can view.
            String scopeLimitation = " customerid in ( "; // ConfigurationManager.AppSettings["TDB_ScopeLimitation"];
            scopeLimitation = scopeLimitation + "'" + GetSelectedCustomer() + "'";
            scopeLimitation = scopeLimitation + GetSelectedCustomerSubCustomers(GetSelectedCustomer()) + " ) ";
            return scopeLimitation;
        }
 
        private String GetSelectedCustomer()
        {
            return CustomerSelector.SelectedValue;
        }
 
        private String GetSelectedCustomerSubCustomers(String customer)
        {
            if (customer == "1001005")
                return " , '1004515', '1004516', '1005417','1004517', '1005301', '1005578', '1005579', '1005580', '1007909', '1008578', '1010285', '1010834'";
            else
                return "";
        }
    }
}


Daniel
Telerik team
 answered on 13 May 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?