Monday, July 29, 2013

[Telerik Reporting] Export to CSV: First column becomes row values

I am creating a dynamic report based on a report template and the fields selected. When I export to csv, the first column has repeating data (of the first column).

Here's my web.config settings:
<configSections>
    <section name="Telerik.Reporting" type="Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting, Version=7.0.13.426, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere"/>
  </configSections>

  <Telerik.Reporting>
    <Extensions>
      <Render>
        <Extension name="CSV">
          <Parameters>
            <Parameter name="NoHeader" value="false"/>
            <Parameter name="NoStaticText" value="true"/>
          </Parameters>
        </Extension>
      </Render>
    </Extensions>
  </Telerik.Reporting>

in the ReportTemplate.cs: private void table1_ItemDataBinding(object sender, EventArgs e)
        {
... //for loop - iterate all selected fields
   var textBox = new Telerik.Reporting.TextBox();
                            textBox.Name = colHeader;
                            textBox.Size = new SizeU(Unit.Inch(width), Unit.Inch(0.3));
                            textBox.CanGrow = true;
                            textBox.StyleName = "Data";
                            textBox.Value = "=Fields.[" + strColumn + "]";

...
         }

I don't experience this issue in static reports, I have placed this workaround inside the constructor:
       
       public Contracts()
        {
            InitializeComponent();

            this.textBox8.Name = "Contract Number";
            this.textBox9.Name = "Date Contract Received";
            this.textBox10.Name = "Deadline Date";
            this.textBox11.Name = "Date of Original Contract";
            this.textBox12.Name = "Contract Execution Date";
            this.textBox13.Name = "Contract Effective Date";
            this.textBox14.Name = "Contract Expiration Date";
            //this.table1.ItemDataBinding += new EventHandler(table1_ItemDataBinding);
        }

Here's the output:



Found out that what's causing exported CSV's first column to become row values was the obsolete NavigateToReportAction.Parameters for sorting

I commented that part and voila, that solved the problem.



Header Image doesn't Display on Telerik Report through Silverlight Report Viewer

Problem: The header image doesn't display on Telerik Report when viewed through Silverlight Report Viewer. But when exported, the image is being displayed.

Solution: 
From Telerik Reporting KB Article

PROBLEM
Images, Charts, Barcodes and Shapes are not being displayed in the Silverlight report viewer.

DESCRIPTION
When a report is previewed in the Silverlight report viewer, Images, Charts, Barcodes and Shapes are missing, however they are present when exporting to one of the supported formats.

SOLUTION
The most probable reason is missing resource endpoint for the Telerik Reporting WCF Servicethat is responsible for serving all images: Picturebox, Chart, Shapes and Barcodes. For proper configuration please refer to the Hosting WCF Service in IIS help article. 
The Silverlight report viewer lives entirely on the client side, while the report rendering is performed on the server. The XAML rendering extension (used by Silverlight report viewer)streams images as resources (similar to HTML), so if the resource endpoint is missing in the service configuration, the images would not be served. When exporting, images are embeddedin the export file.


For SSL: See How to: Enable SSL for Telerik Reporting WCF service


Related Forum Thread: Embedded Image Resources not rendering in Silverlight ReportViewer

Next:
* Take a look at the Custom Binding and its use on Silverlight Application and Telerik Reporting WCF Service

Monday, June 17, 2013

Uninstall IE10 and Get back to IE9 on Windows 7

Ever since I've installed IE10, I have been experiencing issues when it comes to debugging my program. Oftentimes, IE10 crashes. So, I've just decided to uninstall it.

Here's the process:

1. Click on the “Start” button and type “Programs and Features” in the search box.

2. Click on the “View installed updates” in the left pane of the menu.

3. Go over to the “Uninstall an update” screen and scroll down to the “Microsoft Windows” section. Simply select Internet Explorer 10 and click “Uninstall.”

4. Wait until the updates are uninstalled then reboot.

via SoftPedia

Saturday, June 15, 2013

Restore Database Failed: Exclusive access could not be obtained because the database is in use

Solution 1: Set to single user, then restore
Alter Database [<Database Name>]
  SET SINGLE_USER With ROLLBACK IMMEDIATE

RESTORE DATABASE [<Database Name>] FROM  DISK = N'E:\Databases\SampleDatabase.bak' WITH  FILE = 1,  MOVE N'Tfs_Silverlight' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDatabase.mdf',  MOVE N'SampleDatabase_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDatabase.LDF',  NOUNLOAD,  REPLACE,  STATS = 10
GO

Solution 2: Restart SQL Server service
1. Start -> Run and type in services.msc
2. Right click on the SQL Server instance (MSSQLSERVER), click Stop and then Start the service
3. Do the restore process

Thursday, June 13, 2013

SQL Server 2008: Saving Changes is not permitted

Scenario:
When you use Data Definition Language (DDL) to modify a table, and then you try to save the table in Microsoft SQL Server 2008, you may receive the following message:

Error:
Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

Solution:
1. Go to: Tools > Options

2. Select the tab Designers and choose Tables and designers

3. Uncheck the option: "Prevent saving changes that require table re-creation".

4. Save, of course!

Thursday, June 6, 2013

No column header when exporting to CSV from Telerik Report

Check the config file. Make sure that the NoHeader attribute is set to "false"
<Telerik.Reporting>
<Extensions>
<Render>
<Extension name="CSV">
<Parameters>
<Parameter name="NoHeader" value="false"/>
<Parameter name="NoStaticText" value="true"/>
</Parameters>
</Extension>
</Render>
</Extensions>
</Telerik.Reporting>


What if you see the textboxes names and you don't want it of course?

namespace ClassLibrary3
{
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;

    /// <summary>
    /// Summary description for Report1.
    /// </summary>
    public partial class Report1 : Telerik.Reporting.Report
    {
        public Report1()
        {
            /// <summary>
            /// Required for telerik Reporting designer support
            /// </summary>
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            this.textBox1.Name = "Text Box 1";
            this.textBox2.Name = "Text Box 2";
            this.textBox3.Name = "Text-Box-3";

        }
    }
}


Set the textboxes names according to your desired column header names.

Saturday, June 1, 2013

Telerik Report export to CSV has extra columns and headers of control names

Solution:
Configure the CSV rendering extension

Implementation:
By default the CSV rendering extension generates plain text files, without any formatting, and the first row contains the headers for all columns (you may choose whether to have this header row or not).

In Telerik Reporting, device information settings are used to pass rendering parameters to a rendering extension. You can specify device information settings in a variety of ways. You can use the <Telerik.Reporting> configuration section to specify rendering parameters globally. Programmatically, you can use the ReportProcessor.RenderReport() method. For more information about specifying rendering parameters globally, see Configuring Telerik Reporting.

The example below shows a sample application configuration file (App.config or Web.config depending on whether it is a Windows Forms or ASP.NET application) in which we modify the original CSV rendering extension settings to generate a CSV file without the header row (NoHeader = True) and all TextBox items that contain static text (not an expression) skipped (NoStaticText = True):
 
<?xml version="1.0"?> 
<configuration> 
  <!-- The configSectins element should be the first child element of configuration --> 
  <configSections> 
   <!-- Substitute Version=X.X.X.X with the assembly version you are using! --> 
   <section 
      name="Telerik.Reporting" 
      type="Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting, Version=X.X.X.X, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" 
      allowLocation="true" 
      allowDefinition="Everywhere"/> 
  </configSections> 
       
  <Telerik.Reporting> 
    <Extensions> 
      <Render> 
        <Extension name="CSV"
          <Parameters> 
            <Parameter name="NoHeader" value="true"/> 
            <Parameter name="NoStaticText" value="true"/> 
          </Parameters> 
        </Extension> 
      </Render> 
    </Extensions> 
  </Telerik.Reporting> 
</configuration> 

If the report exported with default settings looked like this:

addressIDCaptionTextBox1,cityCaptionTextBox1,postalCodeCaptionTextBox1,textBox1,cityDataTextBox,postalCodeDataTextBox  
AddressID,City,PostalCode,20,Bothell,98011  
AddressID,City,PostalCode,21,Bothell,98011  
AddressID,City,PostalCode,22,Portland,97205  
AddressID,City,PostalCode,23,Seattle,98104  
AddressID,City,PostalCode,24,Duluth,55802  
AddressID,City,PostalCode,25,Dallas,75201  
AddressID,City,PostalCode,26,San Francisco,94109  
AddressID,City,PostalCode,27,Nevada,84407  
AddressID,City,PostalCode,28,Phoenix,85004  
AddressID,City,PostalCode,29,Memphis,38103  
AddressID,City,PostalCode,30,Orlando,32804  
AddressID,City,PostalCode,31,Ottawa,K4B 1T7  
AddressID,City,PostalCode,32,Montreal,H1Y 2H5 

With the given device information you will get:

20,Bothell,98011  
21,Bothell,98011  
22,Portland,97205  
23,Seattle,98104  
24,Duluth,55802  
25,Dallas,75201  
26,San Francisco,94109  
27,Nevada,84407  
28,Phoenix,85004  
29,Memphis,38103  
30,Orlando,32804  
31,Ottawa,K4B 1T7  
32,Montreal,H1Y 2H5  

Source: Configuring the CSV Rendering Extension

Monday, May 27, 2013

Solved: CLR20r3 mtm.exe System.TypeLoadException

System: Windows 7, MS Visual Studio 10 Ultimate

Summary: Error occurs in the Microsoft Test Manager when I try to open or create a new test case.

Error Returned:
Problem signature:
  Problem Event Name: CLR20r3
  Problem Signature 01: mtm.exe
  Problem Signature 02: 10.0.0.0
  Problem Signature 03: 4ba21172
  Problem Signature 04:
Microsoft.TeamFoundation.TestManagement.Activities.Common
  Problem Signature 05: 10.0.0.0
  Problem Signature 06: 4ba21169
  Problem Signature 07: 32
  Problem Signature 08: e
  Problem Signature 09: System.TypeLoadException
  OS Version: 6.1.7601.2.1.0.768.3
  Locale ID: 1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Solution:

1. Reapply MS Visual Studio Service Pack 1.

2. Apply the hotfix rollup package that resolves the following issues in Microsoft Test Manager 2010 and that is dated October 2010 from Microsoft Support. Downloaded the KB2387011 fix from Microsoft Connect.

3. Check for related Windows Update and install.

Note:
My Silverlight has been affected by the fixes. The Visual Studio notified me that I needed the correct version of the Silverlight. The link for that was provided. Downloaded and installed the compatible Silverlight version.

Sunday, May 26, 2013

How to Key in Product Key in Visual Studio

Your trial period has already expired. You now want to register the product after purchasing a license.

Solution 1:
1. Go to Control Panel via Add or Remove Programs
2. Look for Microsoft Visual Studio <YourVersion>. Right click, then click Uninstall/Change.
3. It will load the installation components. Just wait until you go to the Maintenance Page.
4. At the lowest part of the window, you will see the textboxes to key in the Product Key.

Solution 2:
Here's a much simpler solution. Hehe...

MSDN says, to upgrade from a trial edition of Visual Studio Professional, Premium, or Ultimate, the following simple steps are just what you need to do:

1. Start Visual Studio in Run as Administrator mode.
2. On the menu bar, choose Help, Register Product.
3. Specify the product key, and then choose the Next button.

Wednesday, May 22, 2013

Validate Checkbox using Asp.Net Validator

In the designer / .aspx:


<asp:CheckBox ID="chkAgree" runat="server" />I agree to the <a href="#" class="link-blue"> Terms of Service</a> and <a href="#" class="link-blue">Privacy Policy</a>

<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidateCheckBox" CssClass="field_validation" ErrorMessage="Please accept our Terms of Service in order to avail our services."                 ></asp:CustomValidator>

and the Javascript code:

<script type="text/javascript">
    function ValidateCheckBox(sender, args) {
       if (document.getElementById("<%=chkAgree.ClientID %>").checked == true) 
          {
            args.IsValid = true;
          } 
          else 
          {
            args.IsValid = false;
          }
       }
</script>

Sunday, May 19, 2013

Basic template for Transactions in Sql Server


SET XACT_ABORT ON;

BEGIN TRY
    BEGIN TRANSACTION;

    -- Code goes here

    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
     ROLLBACK TRANSACTION;

    DECLARE
     @ERROR_SEVERITY INT,
     @ERROR_STATE INT,
     @ERROR_NUMBER INT,
     @ERROR_LINE  INT,
     @ERROR_MESSAGE NVARCHAR(4000);

    SELECT
     @ERROR_SEVERITY = ERROR_SEVERITY(),
     @ERROR_STATE = ERROR_STATE(),
     @ERROR_NUMBER = ERROR_NUMBER(),
     @ERROR_LINE  = ERROR_LINE(),
     @ERROR_MESSAGE = ERROR_MESSAGE();

    RAISERROR('Msg %d, Line %d, :%s',
     @ERROR_SEVERITY,
     @ERROR_STATE,
     @ERROR_NUMBER,
     @ERROR_LINE,
     @ERROR_MESSAGE);
END CATCH

Source

Sunday, April 21, 2013

[Resolved] ~/Telerik.Web.UI.WebResource.axd is missing in web.config.

Changed from integrated pipeline to classic.

References:
Telerik forum
Brad Kingsley

[Solved] Could not load type 'System.ServiceModel.Activation.HttpModule'


For Windows 7 and Windows Server 2008, use the ASP.NET IIS Registration Tool (aspnet_regiis.exe,) to register the correct version of ASP.NET. For more information about the aspnet_regiis.exe, see ASP.NET IIS Registration Tool.

To register the correct version of ASP.NET

  1. On the computer that is running Microsoft Dynamics NAV Web Server components, open a command prompt as an administrator as follows:
    1. From the Start menu, choose All Programs, and then choose Accessories.
    2. Right-click Command Prompt, and then choose Run as administrator.
  2. At the command prompt, type the following command to change to the Microsoft.NET\Framework64\v4.0.30319 folder, and then press Enter.
    cd\Windows\Microsoft.NET\Framework64\v4.0.30319
  3. At the command prompt, type the following command, and then press Enter.
    aspnet_regiis.exe -iru
  4. At the command prompt, type the following command, and then press Enter.
    iisreset

Source: MSDN Library

Errors: 530 Valid hostname is expected. 530 User cannot log in, home directory inaccessible.

I'm getting problems when connecting to FTP server using FileZilla.
IIS Version 7

Problem 1: 530 Valid hostname is expected.
Solution:
Login as
         Host: example.domain.com
         Username: example.domain.com|Username
... and of course, the Password and Port

Problem 2: 530 User cannot log in, home directory inaccessible.
Solution: 
1. Configure FTP Authentication. Add Basic Authentication.
2. Configure FTP Authorization Rules settings. Add your usename, check Read and/or Write.

Voila! It works!

Tuesday, March 26, 2013

Show Confirm window through code behind


http://www.telerik.com/community/forums/aspnet-ajax/window/need-to-show-confirm-window-through-
code-behind.aspx

Friday, March 22, 2013

Use UpdateProgress To Cover Screen

http://blog.oscarscode.com/dot-net/use-updateprogress-to-cover-screen/

Monday, February 18, 2013

My Sql Templates

Properties

select 'signUp.' + column_name + ' = .Text;' from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME like 'Signup'



Wednesday, January 30, 2013

References Not Found on .g.i.cs files

Just CLEAN and REBUILD the solution. It works! ;)