Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
66 views
How can i click the weekview header to  change to the  dayview
for example the  weekview  header is  monday,19,   click ,monday,19,
change to dayview and the dayview select day is  19.
Thanks!
h
Top achievements
Rank 1
 asked on 18 Sep 2009
1 answer
57 views
Hi!

In my page I have a couple of comboboxes, a grid and a button. The structure of the grid is a three-level hierarchy: Properties -> Buildings -> Objects. The datasource of the grid is specified from choices the user has made from the comboboxes. Its not an option to load all items clientside because when an item is expanded i need to run some checks and maybe modify the items. When the button is clicked the LoadGrid method fires and loads the grid with the correct datasources, one datasource for every level in the hierarchy. Because of the grid loading in the buttonclick-event the datasource disappears for example when i try expanding an item.
How can I persist the datasource of the grid?

I have tried to load the grid in the Page_Init event, as in the example http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html,  which works fine but then i will not be able to filter the datasource from the comboboxes.

The structure of the grid is created as in the example above with the only difference that the method fires in the ButtonClick event instead of the Page_Init event.

Regards, Johannes


Mira
Telerik team
 answered on 18 Sep 2009
1 answer
150 views
Problem Overview:
We are utilizing the RadDock controls to provide some dashboard/portal like functionality in our web site.  Users are allowed to add RadDocks to the page dynamically.  We have closely followed the example given at this website: http://demos.telerik.com/aspnet-ajax/dock/examples/dynamicdocks/defaultcs.aspx  Essentially, the issue seems to appear when we are utizing AJAX to automatically post back for all dockposition changes.  I have seen several types of these questions raised via google/telrik searches, but none specifically identical to my situation.  So, I have created a sample project which is a whittled down, simplified version of our real application which demonstrates the issue.

The most prominent javascript error seems to be:
Webpage error details 
 
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; MDDR; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) 
Timestamp: Wed, 16 Sep 2009 21:39:37 UTC 
 
 
Message: 'undefined' is null or not an object 
Line: 5033 
Char: 2 
Code: 0 
URI: http://as-qa-vm/AIMSNET/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_scriptManager_HiddenField&compress=1&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2009.2.826.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3ad2d891f5-3533-469c-b9a2-ac7d16eb23ff%3a874f8ea2%3a24ee1bba%3a19620875%3a33108d14%3abd8f85e4%3ae330518b%3a1e771326%3ac8618e41%3a854aa0a7%3a5a6d9d23 
 




Symptoms/Cause
When users quickly move RadDocks around on the page the position of the RadDocks seem to get lost and they free float on the page causing javascript errors.  A sure fire way to cause this error seems to be rapidly double clicking on the header bar of a RadDock.  This will eventually result in a JavaScript error in which subsequent actions cause page to have several javascript errors rending the page useless.

Please NOTE:  Double clicking was not the only method used to create the random javascript errors, however it seems to be the best way to easily reproduce the issue.  I think all the javascript errors we have seen stem from the same root issue, whatever that may be.

We have tried several variations of using UpdatePanel and the RadAjaxPanel with Loading Panel.  Any help that anyone can give would be appreciated.

Sample ASPX Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadAjaxPanelDoesNotWork.aspx.cs" Inherits="WebUI.RadAjaxPanelDoesNotWork" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!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></title
</head> 
<body> 
<form id="form1" runat="server"
     
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        </telerik:RadScriptManager> 
         
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="Column1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Column1"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Column2"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Column3"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="Column2"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Column1"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Column2"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Column3"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="Column3"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Column1"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Column2"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                        <telerik:AjaxUpdatedControl ControlID="Column3"  
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
         
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"  
            Skin="Default" MinDisplayTime="500"
        </telerik:RadAjaxLoadingPanel> 
         
        <asp:Button ID="btnAdd" OnClick="btnAdd_Click" runat="server" Text="Add Dock"/> 
 
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
                    <telerik:RadDockLayout runat="server" ID="radDockLayout" OnSaveDockLayout="radDockLayout_SaveDockLayout" OnLoadDockLayout="radDockLayout_LoadDockLayout"
                        <table style="width:99%;"
                        <tr> 
                        <td style="width: 30%;" valign="top" runat="server" Id="tblColumn1"
                            <telerik:RadDockZone runat="server" ID="Column1" Orientation="vertical" Style="border: 0px; width: 100%; min-height: 400px; min-width:100px"
                            </telerik:RadDockZone> 
                        </td> 
                        <td style="width: 30%;" valign="top" runat="server" Id="tblColumn2"
                            <telerik:RadDockZone runat="server" ID="Column2" Orientation="vertical" Style="border: 0px; width: 100%; min-height: 400px; min-width:100px"
                            </telerik:RadDockZone> 
                        </td>                     
                        <td style="width: 30%;" valign="top" runat="server" Id="tblColumn3"
                            <telerik:RadDockZone runat="server" ID="Column3" Orientation="vertical" Style="border: 0px; width: 100%; min-height: 400px; min-width:100px;"
                            </telerik:RadDockZone> 
                        </td> 
                        </tr> 
                        </table> 
                    </telerik:RadDockLayout>                   
            </telerik:RadAjaxPanel> 
    </form> 
</body> 
</html> 
 
 


Code Behind
using System; 
using System.Collections.Generic; 
using System.Threading; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
 
namespace WebUI 
    public partial class RadAjaxPanelDoesNotWork : System.Web.UI.Page 
    { 
        private IList<DockState> dockStates = new List<DockState>(); 
        private bool shouldSaveDocks = true
 
        #region page events 
        protected void Page_Init(object sender, EventArgs e) 
        { 
            LoadDocks(); 
        } 
 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!Page.IsPostBack) 
            { 
                shouldSaveDocks = false
            } 
        } 
 
        protected void radDockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e) 
        { 
            //Populate the event args with the state information. The RadDockLayout control 
            //will automatically move the docks according that information. 
            var savedDockStates = GetDockStates(); 
 
            foreach (DockState dockState in savedDockStates) 
            { 
                e.Positions[dockState.UniqueName] = dockState.DockZoneID; 
                e.Indices[dockState.UniqueName] = dockState.Index; 
            } 
        } 
 
        protected void radDockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e) 
        { 
            //Save the dock state in the db. This will enable us 
            // to recreate the dock in the next Page_Init. 
            if (shouldSaveDocks) 
            { 
                List<DockState> dockStatesToSave = ((RadDockLayout)sender).GetRegisteredDocksState(); 
                SaveDockStates(dockStatesToSave); 
            } 
        } 
 
        protected void btnAdd_Click(object sender, EventArgs e) 
        { 
            RadDock dock = CreateRadDock(); 
            Column1.Controls.Add(dock); 
            CreateSaveStateTrigger(dock); 
            dock.Title = "Sample User Control"
            LoadWidget(dock); 
        } 
        #endregion 
 
        #region Helper Methods 
        private void LoadDocks() 
        { 
            dockStates = GetDockStates(); 
 
            //Recreate the docks in order to ensure their proper operation 
            foreach (DockState dockState in dockStates) 
            { 
                if (dockState.Closed == false) 
                { 
                    RadDock dock = CreateRadDockFromState(dockState); 
                    //We will just add the RadDock control to the RadDockLayout. 
                    // You could use any other control for that purpose, just ensure 
                    // that it is inside the RadDockLayout control. 
                    // The RadDockLayout control will automatically move the RadDock 
                    // controls to their corresponding zone in the LoadDockLayout 
                    // event (see below). 
                    radDockLayout.Controls.Add(dock); 
                    //We want to save the dock state every time a dock is moved. 
                    CreateSaveStateTrigger(dock); 
                    LoadWidget(dock); 
                } 
            } 
        } 
 
        private IList<DockState> GetDockStates() 
        { 
            List<DockState> _currentDockStates = (List<DockState>)Session["DockStates"]; 
            if (Object.Equals(_currentDockStates, null)) 
            { 
                _currentDockStates = new List<DockState>(); 
                Session["DockStates"] = _currentDockStates; 
            } 
            return _currentDockStates; 
        } 
 
        private void SaveDockStates(IEnumerable<DockState> dockStatesToSave) 
        { 
            Session["DockStates"] = dockStatesToSave; 
        } 
 
        private static RadDock CreateRadDockFromState(DockState state) 
        { 
            var dock = new RadDock { DockModeDockMode = DockMode.Docked, EnableAnimation = trueSkin = "Default"ID = string.Format("RadDock{0}", state.UniqueName) }; 
            dock.ApplyState(state); 
            //dock.EnableAnimation = false
            dock.Commands.Add(new DockCloseCommand()); 
            dock.Commands.Add(new DockExpandCollapseCommand()); 
 
            return dock; 
        } 
 
        private static RadDock CreateRadDock() 
        { 
            var dock = new RadDock { DockModeDockMode = DockMode.Docked, EnableAnimation = trueSkin = "Default"UniqueName = Guid.NewGuid().ToString() }; 
            dock.ID = string.Format("RadDock{0}", dock.UniqueName); 
            //dock.EnableAnimation = false
            dock.Commands.Add(new DockCloseCommand()); 
            dock.Commands.Add(new DockExpandCollapseCommand()); 
 
            return dock; 
        } 
 
        private void CreateSaveStateTrigger(RadDock dock) 
        { 
            //Ensure that the RadDock control will initiate postback 
            // when its position changes on the client or any of the commands is clicked. 
            //Using the trigger we will "ajaxify" that postback. 
            dock.AutoPostBack = true
            dock.CommandsAutoPostBack = true
 
        } 
 
        private void LoadWidget(RadDock dock) 
        { 
            Control widget = LoadControl("~/UserControls/SampleUserControl.ascx"); 
            dock.ContentContainer.Controls.Add(widget); 
        } 
 
        #endregion 
 
    } 
 


Pero
Telerik team
 answered on 18 Sep 2009
1 answer
157 views
I want the context menu to show on nodes that are dynamically created in the _TreeView_NodeExpand event.  The context menu is displaying instead only on the root node which I don't want.  By the way, I have the very latest version of the ASP.NET AJAX controls.

I create the context menu in the .aspx file as follows:

 

                          <telerik:RadTreeView  ID="AvailableDataFields_TreeView" runat="server"  on  OnClientContextMenuItemClicked="ContextMenuClick"   OnClientDoubleClick="LinkField">  
                           <ContextMenus> 
                               <telerik:RadTreeViewContextMenu runat="server" ID="RadTreeViewContextMenu1" ClickToOpen="True" > 
                                   <Items> 
                                    <telerik:RadMenuItem   ImageUrl="../../images/Data.gif" Text="Add to Data Tab"></telerik:RadMenuItem> 
                                    <telerik:RadMenuItem ImageUrl="../../images/Filter.gif" Text="Add to Filter Tab"></telerik:RadMenuItem> 
                                    <telerik:RadMenuItem ImageUrl="../../images/Sort.gif" Text="Add to Order Tab"></telerik:RadMenuItem> 
                                   </Items>                        
                               </telerik:RadTreeViewContextMenu> 
                           </ContextMenus> 
                        </telerik:RadTreeView> 

Then in the Page_Load event I add nodes to the tree dynamically and this node level displays the context menu which I don't want.
            oData = oCmd.ExecuteReader  
            Do While oData.Read  
                Dim oNode As New RadTreeNode  
 
                sDesc = oData("Description").ToString  
                If sDesc.Length > 50 Then  
                    sDescsDesc = sDesc.Substring(0, 49) & "..."  
                End If  
 
                With oNode  
                    .ToolTip = "Alias: " & oData("Alias").ToString & vbCrLf & "Description: " & sDesc  
                    .Value = oData("TableID")  
                    .ExpandMode = TreeNodeExpandMode.ServerSideCallBack  
                    .Text = oData("Alias").ToString  
                End With  
 
                AvailableDataFields_TreeView.Nodes.Add(oNode)  
 
            Loop  
 

When I get to the NodeExpand event I add more nodes but the context menu doesn't show there.

 
            Do While oData.Read  
                Dim oNode As New RadTreeNode  
 
                With oNode  
                    .ToolTip = sTooltip 
                    .Text = oData("Alias").ToString  
                    .ExpandMode = TreeNodeExpandMode.ClientSide  
                    .Value = oData("FieldID")  
                    .ContextMenuID = "Report" 
                    .CssClass = "TreeInnerNode" 
                    .HoveredCssClass = "TreeInnerNodeOver" 
                    .EnableContextMenu = True 
                End With  
 
                e.Node.Nodes.Add(oNode) 

What should I do to display the nodes on the correct level?  If I put .EnableContextMenu = false on the first level then there are no context menus anywhere on the tree.

Veselin Vasilev
Telerik team
 answered on 18 Sep 2009
1 answer
131 views
Hi,

I am using radeditor.

When i export the radeditor content to pdf.
It show me the pdf without formatting.
In RadEditor for every newline it create br tag.
But while exporting to pdf it remove all the br tag.

The Format suppose i type in radeditor as

" Hi,

 To Acs,

      Txy........


Regards,
Xyz "


while exporting to pdf it show me the  as below.

" Hi,
 To Acs,
      Txy........
Regards,
Xyz "


So how can i maintain the same formatting while exporting to pdf ?

Thanks.


 
Rumen
Telerik team
 answered on 18 Sep 2009
1 answer
89 views
Hi,
I want make this example to Entities
http://blogs.telerik.com/vladimirenchev/posts/08-09-09/how_to_telerik_radgrid_master_detail_client-side_data-binding_using_linq_to_sql_and_webservice.aspx
but I get empty Grid in Default.aspx

I change  in WebService.asmx :
IQueryable<Customer> customers = new DataClassesDataContext().Customers.AsQueryable<Customer>();
IQueryable<Order> orders = new DataClassesDataContext().Orders.AsQueryable<Order>();
to:
IQueryable<Customers> customers = new NORTHWINDModel.NORTHWINDEntities().Customers.AsQueryable<Customers>();
IQueryable<Orders> orders = new NORTHWINDModel.NORTHWINDEntities().Orders.AsQueryable<Orders>();
       
http://adek24.comlu.com/EntitiesMasterDetailClientSideDataBinding.zip



   
please help me



Tsvetoslav
Telerik team
 answered on 18 Sep 2009
3 answers
127 views
Hi,

Is there a way to centralize Telerik (and ASP.NET Ajax) scripts (like in aspnet_client directory) ?

We got multiple applications using Telerik, and we'd like to avoid downloading script when starting an application.
If a client already downloaded/cached the scripts with application A, why does it have to download them again with application B ? (both application uses the same Telerik version)

Thanks
B B
Top achievements
Rank 1
 answered on 18 Sep 2009
1 answer
127 views
Hi,
I have a simple pagelayout

<----------- PAGELAYOUT ----------->

<%@ Page language="C#"  ....
<%@ Register TagPrefix="Telerik" Namespace="Telerik.SharePoint.FieldEditor" Assembly="RadEditorSharePoint, Version=5.1.0.0, Culture=neutral, PublicKeyToken=1f131a624888eeed" %>

<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">

 <Telerik:RadHtmlField FieldName="PublishingPageContent" runat="server" InputFieldLabel="Body" id="RichHtmlField"/>

</asp:Content>
<----------- PAGELAYOUT ----------->

When in displaymode it works fine, but when i go in edit mode I get the following exception:
 The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
And the stack trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +11013946
   Telerik.Web.SkinRegistrar.RegisterCssReferences(ISkinnableControl _control) +1116
   Telerik.Web.UI.RadEditor.OnPreRender(EventArgs e) +16
   Telerik.SharePoint.MOSSRadEditor.OnPreRender(EventArgs e) +54
   System.Web.UI.Control.PreRenderRecursiveInternal() +108
...

The solution deployment and feature activation is done without errors. Any ideas on what can cause this behavior?

Stanimir
Telerik team
 answered on 18 Sep 2009
3 answers
124 views
Dear Telerik,

I tried to install the visual studio extentions for Q2, however I couldn't find the installation files. Could you please tell me where to find it?

Thanks a lot,

Robert.
Andrey
Telerik team
 answered on 18 Sep 2009
1 answer
91 views
HI,
    i  am using telerik:RadAjaxLoadingPanel in the cristal report  page ,there report is not working in side the telerik:RadAjaxLoadingPanel .please any one help me
thanks
Chandruk

my code is

<

 

telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Transparency="30"

 

 

BackColor="#E0E0E0">

 

 

<asp:Image Style="margin-top: 10px" ID="Image1" runat="server" AlternateText="Loading..."

 

 

BorderWidth="0px" ImageUrl="~/images/loading.gif"></asp:Image>

 

 

</telerik:RadAjaxLoadingPanel>

 

 

<p class="caption">

 

 

<span>Search / List Contracts</span>

 

 

</p>

 

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="LoadingPanel1">

 

<

 

div class="boxbg aleft">

 

 

 

 

 

<p class="minicaption">

 

 

 

 

Search Criteria

 

</p>

 

 

 

 

 

<p class="note">

 

 

 

 

Enter Search Criteria and click Search button to list units. To list all units,

do not enter any search criteria.

 

</p>

 

 

 

 

 

<fieldset>

 

 

 

 

<%

-- ContractHolderName--%>

 

 

<label class="formlabel">

 

 

 

 

 

<span class="reqfld"></span>Contract Holder Name</label>

 

 

 

 

 

<telerik:RadComboBox ID="raddropdownlistContractHolder" runat="server" Width="300px"

 

 

 

 

 

Height="200px" Skin="Web20" DataTextField="Name" DataValueField="ID" AppendDataBoundItems="true"

 

 

 

 

 

EnableEmbeddedSkins="false" MarkFirstMatch="true">

 

 

 

 

 

</telerik:RadComboBox>

 

 

 

 

 

<br />

 

 

 

 

<%

-- Site Name--%>

 

 

<label class="formlabel">

 

 

 

 

 

<span class="reqfld"></span>Site Name</label>

 

 

 

 

 

<telerik:RadComboBox ID="raddropdownlistSiteName" runat="server" Width="300px" Height="200px"

 

 

 

 

 

Skin="Web20" DataTextField="Name" DataValueField="ID" AppendDataBoundItems="true"

 

 

 

 

 

EnableEmbeddedSkins="false" MarkFirstMatch="true">

 

 

 

 

 

</telerik:RadComboBox>

 

 

 

 

 

<br />

 

 

 

 

<%

--Specialty--%>

 

 

<label for="dropdownlistSpecialties" class="formlabel left">

 

 

 

 

Specialty

</label>

 

 

 

 

 

<telerik:RadComboBox ID="raddropdownlistSpecialties" runat="server" Width="300px"

 

 

 

 

 

Height="200px" Skin="Web20" DataTextField="DisplayName" DataValueField="DisplayID"

 

 

 

 

 

AppendDataBoundItems="true" EnableEmbeddedSkins="false" MarkFirstMatch="true">

 

 

 

 

 

</telerik:RadComboBox>

 

 

 

 

 

<br />

 

 

 

 

<%

--Skills--%>

 

 

<label for="dropdownlistSkills" class="formlabel left">

 

 

 

 

Skills

</label>

 

 

 

 

 

<telerik:RadComboBox ID="raddropdownlistSkills" runat="server" Width="300px" Height="200px"

 

 

 

 

 

Skin="Web20" DataTextField="DisplayName" DataValueField="DisplayID" AppendDataBoundItems="true"

 

 

 

 

 

EnableEmbeddedSkins="false" MarkFirstMatch="true">

 

 

 

 

 

</telerik:RadComboBox>

 

 

 

 

<%

--Report Type--%>

 

 

<label for="dropdownlistSkills" class="formlabel left">

 

 

 

 

Create Report as

</label>

 

 

 

 

 

<asp:RadioButtonList ID="radioReport" runat="server" CssClass="formlabel1" RepeatDirection="Horizontal">

 

 

 

 

 

<asp:ListItem Text="Adobe PDF" Value="pdf" Selected></asp:ListItem>

 

 

 

 

 

<asp:ListItem Text="Microsoft Excel" Value="xls"></asp:ListItem>

 

 

 

 

 

</asp:RadioButtonList>

 

 

 

 

 

</fieldset>

 

 

 

 

 

</div>

 

 

 

 

 

<div class="btnpnl">

 

 

 

 

 

<asp:ImageButton ID="buttonReport" runat="server" CausesValidation="false" OnClick="buttonReport_Click"

 

 

 

 

 

AlternateText="Report" ImageUrl="~/Images/report_btn.gif" OnClientClick="Javascript:Auto() ;" />

 

 

 

 

 

</div>

 

 

</telerik:RadAjaxPanel>

 

 

protected void buttonReport_Click(object sender, EventArgs e)

 

{

 

try

 

 

 

 

{

 

// this.FillBusinessObjects();

 

 

 

 

 

//IList<ClinicalUnit> clinicalUnits = ReportController.RetrieveUnitReportForSearchData();

 

 

 

 

 

// radgridUnits.DataSource = clinicalUnits;

 

 

 

 

 

// radgridUnits.DataBind();

 

 

 

 

 

 

DataSet dataSetUnit = new DataSet();

 

 

DataTable dataTableUnit = ConstructDataTableUnit();

 

 

this.FillBusinessObjects();

 

 

IList<ClinicalUnit> clinicalUnits = ReportController.RetrieveUnitReportForSearchData();

 

 

//radgridUnits.DataSource = clinicalUnits;

 

 

 

 

 

//radgridUnits.DataBind();

 

 

 

 

 

if (clinicalUnits.Count > 0)

 

{

 

for (int i = 0; i < clinicalUnits.Count; i++)

 

{

 

DataRow dataRowUnit = dataTableUnit.NewRow();

 

dataRowUnit[

"UnitID"] = clinicalUnits[i].ID.ToString();

 

dataRowUnit[

"UnitName"] = clinicalUnits[i].Name.ToString();

 

dataRowUnit[

"SiteName"] = clinicalUnits[i].Site.Name.ToString();

 

dataRowUnit[

"Status"] = clinicalUnits[i].StatusText.ToString();

 

dataRowUnit[

"Specialty"] = clinicalUnits[i].Specialty.Name.ToString();

 

dataRowUnit[

"Skills"] = clinicalUnits[i].Skill.Name.ToString();

 

dataRowUnit[

"Population"] = clinicalUnits[i].Population.Name.ToString();

 

dataRowUnit[

"AcceptGrad"] = clinicalUnits[i].IsGraduationText.ToString();

 

dataRowUnit[

"AcceptUnderGraduation"] = clinicalUnits[i].IsUnderGraduationText.ToString();

 

dataRowUnit[

"ServiceLearning"] = clinicalUnits[i].IsServiceLearningText.ToString();

 

dataRowUnit[

"NoOfStudents"] = clinicalUnits[i].NoOfStudent.ToString();

 

dataRowUnit[

"UnitContactName"] = clinicalUnits[i].ContactFirstName.ToString();

 

dataRowUnit[

"UnitContactPhone"] = clinicalUnits[i].ContactPhone.ToString();

 

dataRowUnit[

"UnitContactEmail"] = clinicalUnits[i].ContactEMail.ToString();

 

dataTableUnit.Rows.Add(dataRowUnit);

}

dataSetUnit.Tables.Add(dataTableUnit);

ExportReport(dataSetUnit);

}

 

else

 

 

 

 

ClientScript.RegisterStartupScript(

this.GetType(), "onclick", "<script language='javascript'>alert('No Records Found');</script>");

 

 

}

 

catch (SofturaException softuraException)

 

{

 

// throw softuraException;

 

 

 

 

}

 

catch (Exception exception)

 

{

 

// throw exception;

 

 

 

 

}

}

 

private DataTable ConstructDataTableUnit()

 

{

 

DataTable dtUnit = new DataTable("dataTableUnit");

 

dtUnit.Columns.Add(

"UnitID");

 

dtUnit.Columns.Add(

"UnitName");

 

dtUnit.Columns.Add(

"SiteName");

 

dtUnit.Columns.Add(

"Status");

 

dtUnit.Columns.Add(

"Specialty");

 

dtUnit.Columns.Add(

"Skills");

 

dtUnit.Columns.Add(

"Population");

 

dtUnit.Columns.Add(

"AcceptGrad");

 

dtUnit.Columns.Add(

"AcceptUnderGraduation");

 

dtUnit.Columns.Add(

"ServiceLearning");

 

dtUnit.Columns.Add(

"NoOfStudents");

 

dtUnit.Columns.Add(

"UnitContactName");

 

dtUnit.Columns.Add(

"UnitContactPhone");

 

dtUnit.Columns.Add(

"UnitContactEmail");

 

 

return dtUnit;

 

}

 

private void ExportReport(DataSet dataSetUnit)

 

{

 

string sReportType = radioReport.SelectedValue;

 

 

UnitReportXSD objUnits = new UnitReportXSD();

 

objUnits.Merge(dataSetUnit);

 

ReportDocument rdUnits = new ReportDocument();

 

rdUnits.Load(Server.MapPath(

"UnitReport.rpt"));

 

 

ExportOptions expOpt = new ExportOptions();

 

 

DiskFileDestinationOptions dskOpt = new DiskFileDestinationOptions();

 

rdUnits.SetDataSource(objUnits);

 

string sBaseURL = Request.PhysicalApplicationPath.ToString() + ConfigurationSettings.AppSettings["UnitReportPath"].ToString();

 

 

//FileInfo fileInfo = new FileInfo(sBaseURL + "UnitReport.xls");

 

 

 

 

 

FileInfo fileInfo = new FileInfo(sBaseURL + "UnitReport." + sReportType);

 

fileInfo.IsReadOnly =

false;

 

 

//dskOpt.DiskFileName = sBaseURL + "UnitReport.xls";

 

 

 

 

dskOpt.DiskFileName = sBaseURL +

"UnitReport." + sReportType;

 

expOpt = rdUnits.ExportOptions;

expOpt.ExportDestinationOptions = dskOpt;

expOpt.ExportDestinationType =

ExportDestinationType.DiskFile;

 

 

if (sReportType.ToUpper().Equals("PDF"))

 

expOpt.ExportFormatType =

ExportFormatType.PortableDocFormat;

 

 

else

 

 

 

 

expOpt.ExportFormatType =

ExportFormatType.Excel;

 

rdUnits.Export();

DownloadReport(sReportType);

}

 

private void DownloadReport(string sReportType)

 

{

 

try

 

 

 

 

{

 

string sBaseURL = Request.PhysicalApplicationPath.ToString() + "Units\\UnitReport." + sReportType;

 

Response.ClearHeaders();

Response.AddHeader(

"content-disposition", "attachment; filename=UnitReport." + sReportType);

 

 

if (sReportType.ToUpper().Equals("PDF"))

 

Response.ContentType =

"application/force-download";

 

 

else

 

 

 

 

Response.ContentType =

"application/vnd.ms-excel";

 

Response.WriteFile(sBaseURL);

Response.End();

}

 

catch (Exception ex)

 

{

 

throw new Exception(ex.Message);

 

}

}

Sebastian
Telerik team
 answered on 18 Sep 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?